245597377 / luainterface

Automatically exported from code.google.com/p/luainterface
0 stars 0 forks source link

LoadString and LoadFile leak data on the lua stack #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use LoadString or LoadFile thousands of times.

Program should complete successfully regardless of number of calls to 
LoadString/LoadFile.  Instead, the Lua stack overflows. 

Using LuaInterface 2.0.3 on VC9, WinXP.

The following modification appears to work for every test case I've thrown 
at it so far, but, I'm not a lua expert.  I Changed LoadString in 
Lua.cs:238 to pop values off the stack before returning:
public LuaFunction LoadString(string chunk, string name)
{
  int oldTop = LuaDLL.lua_gettop(luaState);
  if (LuaDLL.luaL_loadbuffer(luaState, chunk, name) != 0)
    ThrowExceptionFromError(oldTop);
  LuaFunction result = translator.getFunction(luaState, -1);
  translator.popValues(luaState, oldTop);
  return result;
}
I made a similar modification to LoadFile.

Original issue reported on code.google.com by Byronhol...@gmail.com on 16 Jun 2009 at 4:11

GoogleCodeExporter commented 8 years ago

Original comment by capre...@gmail.com on 12 Sep 2009 at 4:06

GoogleCodeExporter commented 8 years ago
Fixed in r13

Original comment by capre...@gmail.com on 12 Sep 2009 at 6:29