fix memory leak
Merge pull request #219 from undingen/mem_leak

fix memory leak