A memory leak (patch included)

Moderator: Moderator

Post Reply
Message
Author
Shigerello
Yeek
Posts: 14
Joined: Mon Jan 25, 2010 12:39 pm

A memory leak (patch included)

#1 Post 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);

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: A memory leak (patch included)

#2 Post by darkgod »

Oh thanks :)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply