mascarenhas / alien

A C FFI for Lua
http://mascarenhas.github.com/alien/
143 stars 45 forks source link

Lua stack index bug #54

Open BigJim opened 7 years ago

BigJim commented 7 years ago

In "alien.c" in "alien_buffer_gc" @ line #934: "lua_pop(L, 2);" When "LUA_USE_APICHECK" is defined, this line will trigger a "invalid new top".

This because there is only one stack index (the __gc userdata argument) not two. And actually since there is no return result this call is pointless. The solution is to just delete this unnecessary "lua_pop(L, 2);" line.

Note to readers: In your debug Lua builds that use 3rd party libraries, it's a good idea to define LUA_USE_APICHECK as it will catch odd things like this that corrupt your Lua stack, Lua stack overflows, etc.