From e059c1f5abd602ee860a81a791d743acd427fbc6 Mon Sep 17 00:00:00 2001 From: Vincent Herbet Date: Thu, 20 Sep 2018 23:32:41 +0200 Subject: [PATCH] Fix invalid handle passed in the SMC/INI parser callbacks (#592) --- amxmodx/textparse.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/amxmodx/textparse.cpp b/amxmodx/textparse.cpp index 7ad389ded6..9f4e062c8e 100644 --- a/amxmodx/textparse.cpp +++ b/amxmodx/textparse.cpp @@ -44,7 +44,12 @@ cell destroyParser(cell *handle) // native SMCParser:SMC_CreateParser(); static cell AMX_NATIVE_CALL SMC_CreateParser(AMX *amx, cell *params) { - return createParser(); + const auto handle = createParser(); + const auto parseInfo = TextParsersHandles.lookup(handle); + + parseInfo->handle = handle; + + return handle; } // native SMC_SetParseStart(SMCParser:handle, const func[]); @@ -224,7 +229,12 @@ static cell AMX_NATIVE_CALL SMC_DestroyParser(AMX *amx, cell *params) // native INIParser:INI_CreateParser(); static cell AMX_NATIVE_CALL INI_CreateParser(AMX *amx, cell *params) { - return createParser(); + const auto handle = createParser(); + const auto parseInfo = TextParsersHandles.lookup(handle); + + parseInfo->handle = handle; + + return handle; } // native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0, any:data = 0);