SuperiorServers / gm_tmysql4

MySQL connection module for Garry's Mod servers - SUP has picked up and maintained the module since it was abandoned years ago - Original author: @bkacjios
31 stars 7 forks source link

Lua leak #15

Closed darkjacky closed 4 months ago

darkjacky commented 1 year ago

While not crucial I found a function thats leaking the Lua stack.

void DatabaseAction::TriggerCallback(lua_State* state); The LUA->ReferencePush(tmysql::iRefDebugTraceBack); does not get cleaned up with a LUA->Pop(); PCall does not clean it up by itself.

You should also consider doing this in that function: Right before the PCallint count = LUA->Top(); Then change the PCall to LUA->PCall( count - 2, 0, -count ) This allows you to remove the int args = 1;

Though this entire thing does not work if your LUA->Top(); does not start with 0. Then you should do int top = LUA->Top();before the LUA->ReferencePush(tmysql::iRefDebugTraceBack); and int count = LUA->Top() - top;

However this would add 1 or 2 extra calls so it might not be worth doing.