1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00

macro 'luaV_fastget' may need protection ({}) to be used inside

'if's
This commit is contained in:
Roberto Ierusalimschy 2017-06-01 17:22:33 -03:00
parent 4bc33d64de
commit b029e7ea20
2 changed files with 14 additions and 8 deletions

8
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.267 2017/05/18 12:34:58 roberto Exp roberto $
** $Id: lapi.c,v 2.268 2017/05/26 19:14:29 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -775,8 +775,9 @@ LUA_API void lua_settable (lua_State *L, int idx) {
lua_lock(L);
api_checknelems(L, 2);
t = index2addr(L, idx);
if (luaV_fastget(L, t, L->top - 2, slot, luaH_get))
if (luaV_fastget(L, t, L->top - 2, slot, luaH_get)) {
luaV_finishfastset(L, t, slot, L->top - 1);
}
else
luaV_finishset(L, t, L->top - 2, L->top - 1, slot);
L->top -= 2; /* pop index and value */
@ -796,8 +797,9 @@ LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
lua_lock(L);
api_checknelems(L, 1);
t = index2addr(L, idx);
if (luaV_fastgeti(L, t, n, slot))
if (luaV_fastgeti(L, t, n, slot)) {
luaV_finishfastset(L, t, slot, L->top - 1);
}
else {
TValue aux;
setivalue(&aux, n);

14
lvm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.284 2017/05/18 19:44:19 roberto Exp roberto $
** $Id: lvm.c,v 2.285 2017/05/23 12:50:11 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -916,8 +916,9 @@ void luaV_execute (lua_State *L) {
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr))
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, upval, slot, rc);
}
else
Protect(luaV_finishset(L, upval, rb, rc, slot));
vmbreak;
@ -929,8 +930,9 @@ void luaV_execute (lua_State *L) {
lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */
? (n = ivalue(rb), luaV_fastgeti(L, ra, n, slot))
: luaV_fastget(L, ra, rb, slot, luaH_get))
: luaV_fastget(L, ra, rb, slot, luaH_get)) {
luaV_finishfastset(L, ra, slot, rc);
}
else
Protect(luaV_finishset(L, ra, rb, rc, slot));
vmbreak;
@ -939,8 +941,9 @@ void luaV_execute (lua_State *L) {
const TValue *slot;
int c = GETARG_B(i);
TValue *rc = RKC(i);
if (luaV_fastgeti(L, ra, c, slot))
if (luaV_fastgeti(L, ra, c, slot)) {
luaV_finishfastset(L, ra, slot, rc);
}
else {
TValue key;
setivalue(&key, c);
@ -953,8 +956,9 @@ void luaV_execute (lua_State *L) {
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, ra, key, slot, luaH_getshortstr))
if (luaV_fastget(L, ra, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, ra, slot, rc);
}
else
Protect(luaV_finishset(L, ra, rb, rc, slot));
vmbreak;