Skip to content

Commit

Permalink
Fixed infinite error hook loop
Browse files Browse the repository at this point in the history
Bumped revision number
  • Loading branch information
danielga committed Dec 16, 2021
1 parent d03891b commit e8c9cee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ GMOD_MODULE_OPEN( )
{
LUA->CreateTable( );

LUA->PushString( "luaerror 1.5.6" );
LUA->PushString( "luaerror 1.5.7" );
LUA->SetField( -2, "Version" );

// version num follows LuaJIT style, xxyyzz
LUA->PushNumber( 10506 );
LUA->PushNumber( 10507 );
LUA->SetField( -2, "VersionNum" );

#if defined LUAERROR_SERVER
Expand Down
9 changes: 8 additions & 1 deletion source/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ class CLuaGameCallback : public GarrysMod::Lua::ILuaGameCallback

void LuaError( const CLuaError *error )
{
if( entered_hook )
return callback->LuaError( error );

const int32_t funcs = LuaHelpers::PushHookRun( lua, "LuaError" );
if( funcs == 0 )
return callback->LuaError( error );
Expand Down Expand Up @@ -306,7 +309,10 @@ class CLuaGameCallback : public GarrysMod::Lua::ILuaGameCallback
lua->PushString( std::to_string( source_addon->wsid ).c_str( ) );
}

if( !LuaHelpers::CallHookRun( lua, 4 + args, 1 ) )
entered_hook = true;
const bool call_success = LuaHelpers::CallHookRun( lua, 4 + args, 1 );
entered_hook = false;
if( !call_success )
return callback->LuaError( error );

const bool proceed = !lua->IsType( -1, GarrysMod::Lua::Type::BOOL ) || !lua->GetBool( -1 );
Expand Down Expand Up @@ -339,6 +345,7 @@ class CLuaGameCallback : public GarrysMod::Lua::ILuaGameCallback
private:
GarrysMod::Lua::CLuaInterface *lua;
GarrysMod::Lua::ILuaGameCallback *callback;
bool entered_hook = false;
};

static CLuaGameCallback callback;
Expand Down

0 comments on commit e8c9cee

Please sign in to comment.