From 1509d09ad485a44ee8034cf741e35d44df76cea9 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 26 Dec 2008 08:50:47 +0000 Subject: [PATCH] Check that there is actually an argument at that position before attempting to do something with it. --- stepmania/src/EnumHelper.cpp | 2 ++ stepmania/src/LuaBinding.cpp | 1 + stepmania/src/LuaManager.h | 1 + 3 files changed, 4 insertions(+) diff --git a/stepmania/src/EnumHelper.cpp b/stepmania/src/EnumHelper.cpp index fa2111912f..49e837d33a 100644 --- a/stepmania/src/EnumHelper.cpp +++ b/stepmania/src/EnumHelper.cpp @@ -5,6 +5,8 @@ int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const char *szType, bool bAllowInvalid ) { + luaL_checkany( L, iPos ); + if( lua_isnil(L, iPos) ) { if( bAllowInvalid ) diff --git a/stepmania/src/LuaBinding.cpp b/stepmania/src/LuaBinding.cpp index c25b29b7e2..1e6717a5de 100644 --- a/stepmania/src/LuaBinding.cpp +++ b/stepmania/src/LuaBinding.cpp @@ -226,6 +226,7 @@ bool LuaBinding::CheckLuaObjectType( lua_State *L, int iArg, const char *szType #if defined(FAST_LUA) return true; #endif + luaL_checkany( L, iArg ); /* Check that szType is in metatable.heirarchy. */ if( !luaL_getmetafield(L, iArg, "heirarchy") ) diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index f7ff8e63c1..7102f0ebb3 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -190,6 +190,7 @@ inline bool MyLua_checkboolean (lua_State *L, int numArg) * used to mean "cmd,false". */ inline bool MyLua_checkintboolean( lua_State *L, int iArg ) { + luaL_checkany( L, iArg ); int iType = lua_type( L, iArg ); if( iType == LUA_TNUMBER ) {