Skip to content
Snippets Groups Projects
Commit 971518d2 authored by Golden's avatar Golden
Browse files

Have Lua_OnChange restore the stack to what it was before it was called.

So we don't get Luas with access to LUA_GetErrorMessage.
parent 760e083c
Branches
Tags
1 merge request!1346Fix CV_RegisterVar returning LUA_GetErrorMessage to Lua when CV_CALL is involved. (Resolves #403)
...@@ -285,8 +285,8 @@ static void Lua_OnChange(void) ...@@ -285,8 +285,8 @@ static void Lua_OnChange(void)
/// \todo Network this! XD_LUAVAR /// \todo Network this! XD_LUAVAR
lua_settop(gL, 0); // Just in case...
lua_pushcfunction(gL, LUA_GetErrorMessage); lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_insert(gL, 1); // Because LUA_Call wants it at index 1.
// From CV_OnChange registry field, get the function for this cvar by name. // From CV_OnChange registry field, get the function for this cvar by name.
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
...@@ -301,6 +301,7 @@ static void Lua_OnChange(void) ...@@ -301,6 +301,7 @@ static void Lua_OnChange(void)
LUA_Call(gL, 1, 0, 1); // call function(cvar) LUA_Call(gL, 1, 0, 1); // call function(cvar)
lua_pop(gL, 1); // pop CV_OnChange table lua_pop(gL, 1); // pop CV_OnChange table
lua_remove(gL, 1); // remove LUA_GetErrorMessage
} }
static int lib_cvRegisterVar(lua_State *L) static int lib_cvRegisterVar(lua_State *L)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment