mirror of
https://github.com/lua/lua.git
synced 2026-07-23 06:29:06 +00:00
Avoid an assignment of values that overlap
The original code was like this, where t->u.ind.t and t->u.info overlap: t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
This commit is contained in:
9
lcode.c
9
lcode.c
@@ -827,7 +827,7 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
|
||||
} /* FALLTHROUGH */
|
||||
case VLOCAL: { /* already in a register */
|
||||
int temp = e->u.var.ridx;
|
||||
e->u.info = temp; /* (can't do a direct assignment; values overlap) */
|
||||
e->u.info = temp; /* (avoid a direct assignment; values overlap) */
|
||||
e->k = VNONRELOC; /* becomes a non-relocatable value */
|
||||
break;
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ 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 */
|
||||
t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
|
||||
t->u.ind.t = temp; /* (avoid a direct assignment; values overlap) */
|
||||
lua_assert(isKstr(fs, k));
|
||||
fillidxk(t, k->u.info, VINDEXUP); /* literal short string */
|
||||
}
|
||||
@@ -1373,12 +1373,13 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
||||
int kreg = luaK_exp2anyreg(fs, k); /* put key in some register */
|
||||
lu_byte vreg = cast_byte(t->u.var.ridx); /* register with vararg param. */
|
||||
lua_assert(vreg == fs->f->numparams);
|
||||
t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap) */
|
||||
t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap?) */
|
||||
fillidxk(t, kreg, VVARGIND); /* 't' represents 'vararg[k]' */
|
||||
}
|
||||
else {
|
||||
/* register index of the table */
|
||||
t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
|
||||
lu_byte temp = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
|
||||
t->u.ind.t = temp; /* (avoid a direct assignment; values may overlap?) */
|
||||
if (isKstr(fs, k))
|
||||
fillidxk(t, k->u.info, VINDEXSTR); /* literal short string */
|
||||
else if (isCint(k)) /* int. constant in proper range? */
|
||||
|
||||
Reference in New Issue
Block a user