diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2026-02-09 13:44:27 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2026-02-09 13:44:27 -0300 |
| commit | b60e2bcd7ca4c349bd6ee7a8e929f55e04f7ca87 (patch) | |
| tree | 5bde4fc6bbd95691ffc9b6c2f2fe780ecc83314c /lcode.c | |
| parent | c6b484823806e08e1756b1a6066a3ace6f080fae (diff) | |
| download | lua-b60e2bcd7ca4c349bd6ee7a8e929f55e04f7ca87.tar.gz lua-b60e2bcd7ca4c349bd6ee7a8e929f55e04f7ca87.tar.bz2 lua-b60e2bcd7ca4c349bd6ee7a8e929f55e04f7ca87.zip | |
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);
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -827,7 +827,7 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
| 827 | } /* FALLTHROUGH */ | 827 | } /* FALLTHROUGH */ |
| 828 | case VLOCAL: { /* already in a register */ | 828 | case VLOCAL: { /* already in a register */ |
| 829 | int temp = e->u.var.ridx; | 829 | int temp = e->u.var.ridx; |
| 830 | e->u.info = temp; /* (can't do a direct assignment; values overlap) */ | 830 | e->u.info = temp; /* (avoid a direct assignment; values overlap) */ |
| 831 | e->k = VNONRELOC; /* becomes a non-relocatable value */ | 831 | e->k = VNONRELOC; /* becomes a non-relocatable value */ |
| 832 | break; | 832 | break; |
| 833 | } | 833 | } |
| @@ -1365,7 +1365,7 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
| 1365 | luaK_exp2anyreg(fs, t); /* put it in a register */ | 1365 | luaK_exp2anyreg(fs, t); /* put it in a register */ |
| 1366 | if (t->k == VUPVAL) { | 1366 | if (t->k == VUPVAL) { |
| 1367 | lu_byte temp = cast_byte(t->u.info); /* upvalue index */ | 1367 | lu_byte temp = cast_byte(t->u.info); /* upvalue index */ |
| 1368 | t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ | 1368 | t->u.ind.t = temp; /* (avoid a direct assignment; values overlap) */ |
| 1369 | lua_assert(isKstr(fs, k)); | 1369 | lua_assert(isKstr(fs, k)); |
| 1370 | fillidxk(t, k->u.info, VINDEXUP); /* literal short string */ | 1370 | fillidxk(t, k->u.info, VINDEXUP); /* literal short string */ |
| 1371 | } | 1371 | } |
| @@ -1373,12 +1373,13 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
| 1373 | int kreg = luaK_exp2anyreg(fs, k); /* put key in some register */ | 1373 | int kreg = luaK_exp2anyreg(fs, k); /* put key in some register */ |
| 1374 | lu_byte vreg = cast_byte(t->u.var.ridx); /* register with vararg param. */ | 1374 | lu_byte vreg = cast_byte(t->u.var.ridx); /* register with vararg param. */ |
| 1375 | lua_assert(vreg == fs->f->numparams); | 1375 | lua_assert(vreg == fs->f->numparams); |
| 1376 | t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap) */ | 1376 | t->u.ind.t = vreg; /* (avoid a direct assignment; values may overlap?) */ |
| 1377 | fillidxk(t, kreg, VVARGIND); /* 't' represents 'vararg[k]' */ | 1377 | fillidxk(t, kreg, VVARGIND); /* 't' represents 'vararg[k]' */ |
| 1378 | } | 1378 | } |
| 1379 | else { | 1379 | else { |
| 1380 | /* register index of the table */ | 1380 | /* register index of the table */ |
| 1381 | t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info); | 1381 | lu_byte temp = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info); |
| 1382 | t->u.ind.t = temp; /* (avoid a direct assignment; values may overlap?) */ | ||
| 1382 | if (isKstr(fs, k)) | 1383 | if (isKstr(fs, k)) |
| 1383 | fillidxk(t, k->u.info, VINDEXSTR); /* literal short string */ | 1384 | fillidxk(t, k->u.info, VINDEXSTR); /* literal short string */ |
| 1384 | else if (isCint(k)) /* int. constant in proper range? */ | 1385 | else if (isCint(k)) /* int. constant in proper range? */ |
