Good fix. But shouldn't we free the memory before leaving the function?