diff --git a/EGnLuaAux.h b/EGnLuaAux.h index 0698829..9346d7f 100644 --- a/EGnLuaAux.h +++ b/EGnLuaAux.h @@ -438,6 +438,8 @@ LuaGetGlobVar( lua_State* L, const std::string& sVar, T& Val) std::string sTab, sField ; SplitFirst( sVar, ".", sTab, sField) ; lua_getglobal( L, sTab.c_str()) ; + if ( ! lua_istable( L, -1)) + return false ; bool bOk = LuaGetTabFieldParam( L, -1, sField.c_str(), Val) ; lua_pop( L, 1) ; return bOk ; diff --git a/EGnLuaMgr.h b/EGnLuaMgr.h index 3ee099f..93494c4 100644 --- a/EGnLuaMgr.h +++ b/EGnLuaMgr.h @@ -101,6 +101,8 @@ LuaMgr::CallFunction( const std::string& sFunName, int nRets, const Args&... par std::string sTab, sField ; SplitFirst( sFunName, ".", sTab, sField) ; lua_getglobal( m_pL, sTab.c_str()) ; + if ( ! lua_istable( m_pL, -1)) + return false ; lua_getfield( m_pL, -1, sField.c_str()) ; // porto la funzione uno slot sotto e diminuisco lo stack di uno (per essere come caso sopra) lua_copy( m_pL, -1, -2) ;