Skip to content

Commit fdf2b55

Browse files
committed
voicechat: properly set userdata to NULL
1 parent d02ab7b commit fdf2b55

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

source/modules/voicechat.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ LUA_FUNCTION_STATIC(VoiceData_CreateCopy)
212212
static Detouring::Hook detour_SV_BroadcastVoiceData;
213213
static void hook_SV_BroadcastVoiceData(IClient* pClient, int nBytes, char* data, int64 xuid)
214214
{
215+
VPROF_BUDGET("HolyLib - SV_BroadcastVoiceData", VPROF_BUDGETGROUP_HOLYLIB);
216+
215217
if (g_pVoiceChatModule.InDebug())
216218
Msg("cl: %p\nbytes: %i\ndata: %p\n", pClient, nBytes, data);
217219

@@ -221,8 +223,6 @@ static void hook_SV_BroadcastVoiceData(IClient* pClient, int nBytes, char* data,
221223
return;
222224
}
223225

224-
VPROF_BUDGET("HolyLib - SV_BroadcastVoiceData", VPROF_BUDGETGROUP_HOLYLIB);
225-
226226
if (Lua::PushHook("HolyLib:PreProcessVoiceChat"))
227227
{
228228
VoiceData* pVoiceData = new VoiceData;
@@ -231,15 +231,15 @@ static void hook_SV_BroadcastVoiceData(IClient* pClient, int nBytes, char* data,
231231

232232
Util::Push_Entity((CBaseEntity*)Util::GetPlayerByClient((CBaseClient*)pClient));
233233
Push_VoiceData(pVoiceData);
234+
bool bHandled = false;
234235
if (g_Lua->CallFunctionProtected(3, 1, true))
235236
{
236-
bool bHandled = g_Lua->GetBool(-1);
237+
bHandled = g_Lua->GetBool(-1);
237238
g_Lua->Pop(1);
238-
if (bHandled)
239-
{
240-
return;
241-
}
242239
}
240+
241+
if (bHandled)
242+
return;
243243
}
244244

245245
detour_SV_BroadcastVoiceData.GetTrampoline<Symbols::SV_BroadcastVoiceData>()(pClient, nBytes, data, xuid);

source/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ LUA_FUNCTION_STATIC(className ## __gc) \
394394
{ \
395395
func \
396396
delete pData; \
397+
LUA->SetUserType(1, NULL); \
397398
} \
398399
\
399400
return 0; \

0 commit comments

Comments
 (0)