Fix memory leak when opening from existing file

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>