diff options
author | Michael Muller <mmuller@enduden.com> | 2018-11-28 14:01:01 -0500 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2018-11-28 20:01:01 +0100 |
commit | ddd9317b733857630499972179caebc236b4d991 (patch) | |
tree | e7bf705a27299955480395d348c82a23de260bac /src | |
parent | faa358e797128ab07bb5644ce305a832d59e5596 (diff) | |
download | minetest-ddd9317b733857630499972179caebc236b4d991.tar.gz minetest-ddd9317b733857630499972179caebc236b4d991.tar.bz2 minetest-ddd9317b733857630499972179caebc236b4d991.zip |
Clean up stack after script_get_backtrace (#7854)
script_get_backtrace() was leaving its return value on the stack, corrupting
subsequent lua operations for functions that did not immediately return.
This problem can specifically be observed in the case of multiple "groupcaps"
entries, each of which provides the legacy "maxwear" property. These cause a
backtrace and thus pollute the stack for the following lua_next() call.
Diffstat (limited to 'src')
-rw-r--r-- | src/script/common/c_internal.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp index be9691ef4..f792b6218 100644 --- a/src/script/common/c_internal.cpp +++ b/src/script/common/c_internal.cpp @@ -27,7 +27,9 @@ std::string script_get_backtrace(lua_State *L) { lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE); lua_call(L, 0, 1); - return luaL_checkstring(L, -1); + std::string result = luaL_checkstring(L, -1); + lua_pop(L, 1); + return result; } int script_exception_wrapper(lua_State *L, lua_CFunction f) |