From 7f24e6fad2a8fe7cc9e41ec1db3e96646c9ded13 Mon Sep 17 00:00:00 2001 From: nosoop Date: Wed, 10 Jul 2019 02:03:48 -0700 Subject: [PATCH 1/2] Prevent NativeVote menu from nuking handler Increments the refcount of the private forward. This prevents a crash on Debian 10 and doesn't seem like well-defined behavior. --- addons/sourcemod/scripting/nativevotes.sp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/nativevotes.sp b/addons/sourcemod/scripting/nativevotes.sp index 10df5a1..e7716fc 100644 --- a/addons/sourcemod/scripting/nativevotes.sp +++ b/addons/sourcemod/scripting/nativevotes.sp @@ -46,7 +46,7 @@ EngineVersion g_EngineVersion = Engine_Unknown; #include "nativevotes/data-keyvalues.sp" -#define VERSION "1.1.0 beta 8" +#define VERSION "1.1.1" #define LOGTAG "NV" @@ -821,7 +821,7 @@ Action DoAction(NativeVote vote, MenuAction action, int param1, int param2, Acti { Action res = def_res; - Handle handler = Data_GetHandler(vote); + Handle handler = CloneHandle(Data_GetHandler(vote)); #if defined LOG LogMessage("Calling Menu forward for vote: %d, handler: %d, action: %d, param1: %d, param2: %d", vote, handler, action, param1, param2); #endif @@ -831,6 +831,7 @@ Action DoAction(NativeVote vote, MenuAction action, int param1, int param2, Acti Call_PushCell(param1); Call_PushCell(param2); Call_Finish(res); + delete handler; return res; } From 5a5574644bd3c366bfc36c7c3e0394d76e04a287 Mon Sep 17 00:00:00 2001 From: Benoist Date: Wed, 18 Aug 2021 17:02:16 +0200 Subject: [PATCH 2/2] fix handle leak --- addons/sourcemod/scripting/nativevotes/game.sp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/sourcemod/scripting/nativevotes/game.sp b/addons/sourcemod/scripting/nativevotes/game.sp index 0f63128..fd294b8 100644 --- a/addons/sourcemod/scripting/nativevotes/game.sp +++ b/addons/sourcemod/scripting/nativevotes/game.sp @@ -2368,6 +2368,8 @@ static void TF2CSGO_SendOptionsToClient(NativeVote vote, int client) } optionsEvent.SetInt("count", itemCount); optionsEvent.FireToClient(client); + + delete optionsEvent; } static void CSGO_VotePass(const char[] translation, const char[] details, int team, int client=0)