Skip to content

Commit

Permalink
Fix invalid handle passed in the SMC/INI parser callbacks (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkshine committed Sep 20, 2018
1 parent ddf0cc6 commit e059c1f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions amxmodx/textparse.cpp
Expand Up @@ -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[]);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e059c1f

Please sign in to comment.