From 561405664096f268738fb2cd10b2accd3b551915 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 28 Sep 2015 14:53:50 +0200 Subject: Made Lua API check strings strictly. Previously nil was accepted as a string in cLuaState::CheckParamString(), now it's reported as an error. --- src/Bindings/LuaState.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Bindings/LuaState.cpp') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index c9e7815ca..1509bd19f 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1065,7 +1065,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam) tolua_Error tolua_err; for (int i = a_StartParam; i <= a_EndParam; i++) { - if (tolua_isstring(m_LuaState, i, 0, &tolua_err)) + if (lua_isstring(m_LuaState, i)) { continue; } @@ -1073,6 +1073,9 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam) lua_Debug entry; VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry)); + tolua_err.array = 0; + tolua_err.type = "string"; + tolua_err.index = i; AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?"); tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err); return false; -- cgit v1.2.3