From 395c27bc816e40962f3936acbf22aa2c3f2cd263 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 16 Jan 2017 19:19:04 +0000 Subject: [PATCH] Include : - migliorati controlli in accesso a campi di tavole Lua. --- EGnLuaAux.h | 2 ++ EGnLuaMgr.h | 2 ++ 2 files changed, 4 insertions(+) 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) ;