Fix double-free issue.

Don't play with raw memory!  I should move the code to C++11 to make it
all easier... std::unique_ptr where are thou?!