Fixed dangling malloc