Page 1 of 1

A memory leak (patch included)

Posted: Fri Jan 28, 2011 11:59 am
by Shigerello
I found a memory leak in "core_lua.c".

The memory leak occurs at lua_pushstring(): a returned malloc'd char* string of PHYSFS_getDependentPath() is passed to lua_pushstring().
lua_pushstring() creates a copy of the passed char* string internally, so that responsibility for freeing the malloc'd char* string belongs to T-Engine.
This is simply done by patching a diff below (diff of rev. 2494 vs. local).

Code: Select all

2182c2182,2184
< 	lua_pushstring(L, PHYSFS_getDependentPath(src));
---
> 	char *alloc_path = PHYSFS_getDependentPath(src);
> 	lua_pushstring(L, alloc_path);
> 	free(alloc_path);

Re: A memory leak (patch included)

Posted: Fri Jan 28, 2011 12:18 pm
by darkgod
Oh thanks :)