Fixed double free leading to SIGSEGV