fix memory leak.

From Sergei Linev.