Checks for read-only globals

This commit is contained in:
Roberto Ierusalimschy
2025-05-06 15:54:05 -03:00
parent be81209063
commit 4365a45d68
4 changed files with 33 additions and 9 deletions

View File

@@ -1315,8 +1315,8 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
luaK_exp2anyreg(fs, t); /* put it in a register */
if (t->k == VUPVAL) {
lu_byte temp = cast_byte(t->u.info); /* upvalue index */
lua_assert(isKstr(fs, k));
t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
lua_assert(isKstr(fs, k));
t->u.ind.idx = cast(short, k->u.info); /* literal short string */
t->k = VINDEXUP;
}
@@ -1336,6 +1336,7 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
t->k = VINDEXED;
}
}
t->u.ind.vidx = -1; /* by default, not a declared global */
}