Fixed alloc-dealloc-mismatch problem discovered by AddressSanitizer