Fix potential vulnerable cloned functions: Bug: Lua can generate wrong code when _ENV is <const>

This commit is contained in:
npt-1707 2025-04-24 17:53:22 +08:00 committed by Robin Gareus
parent edf2ce7cfe
commit dd0de15269
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -300,6 +300,7 @@ static void singlevar (LexState *ls, expdesc *var) {
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k != VVOID); /* this one must exist */
luaK_exp2anyregup(fs, var); /* but could be a constant */
codestring(ls, &key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}