Script: Fix table string key UAF

This commit is contained in:
Vicki Pfau 2023-01-31 17:19:01 -08:00
parent 5a5adc1b15
commit e445baaf14
1 changed files with 5 additions and 1 deletions

View File

@ -584,7 +584,11 @@ struct mScriptValue* _luaCoerceTable(struct mScriptEngineContextLua* luaContext)
return false;
}
mScriptTableInsert(table, key, value);
mScriptValueDeref(key);
if (key->type != mSCRIPT_TYPE_MS_STR) {
// Strings are added to the ref pool, so we need to keep it
// ref'd to prevent it from being collected prematurely
mScriptValueDeref(key);
}
mScriptValueDeref(value);
}
lua_pop(luaContext->lua, 1);