aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-01 17:22:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-01 17:22:33 -0300
commitb029e7ea2070b834e1061492367faa11a1d54e3c (patch)
treeee1e411a0e05e34273ecf20dd5c0a203c081be56
parent4bc33d64de9bb2c1cd96240337ba8486300759da (diff)
downloadlua-b029e7ea2070b834e1061492367faa11a1d54e3c.tar.gz
lua-b029e7ea2070b834e1061492367faa11a1d54e3c.tar.bz2
lua-b029e7ea2070b834e1061492367faa11a1d54e3c.zip
macro 'luaV_fastget' may need protection ({}) to be used inside
'if's
-rw-r--r--lapi.c8
-rw-r--r--lvm.c14
2 files changed, 14 insertions, 8 deletions
diff --git a/lapi.c b/lapi.c
index 0c109e1e..d78d9455 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.267 2017/05/18 12:34:58 roberto Exp roberto $ 2** $Id: lapi.c,v 2.268 2017/05/26 19:14:29 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -775,8 +775,9 @@ LUA_API void lua_settable (lua_State *L, int idx) {
775 lua_lock(L); 775 lua_lock(L);
776 api_checknelems(L, 2); 776 api_checknelems(L, 2);
777 t = index2addr(L, idx); 777 t = index2addr(L, idx);
778 if (luaV_fastget(L, t, L->top - 2, slot, luaH_get)) 778 if (luaV_fastget(L, t, L->top - 2, slot, luaH_get)) {
779 luaV_finishfastset(L, t, slot, L->top - 1); 779 luaV_finishfastset(L, t, slot, L->top - 1);
780 }
780 else 781 else
781 luaV_finishset(L, t, L->top - 2, L->top - 1, slot); 782 luaV_finishset(L, t, L->top - 2, L->top - 1, slot);
782 L->top -= 2; /* pop index and value */ 783 L->top -= 2; /* pop index and value */
@@ -796,8 +797,9 @@ LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) {
796 lua_lock(L); 797 lua_lock(L);
797 api_checknelems(L, 1); 798 api_checknelems(L, 1);
798 t = index2addr(L, idx); 799 t = index2addr(L, idx);
799 if (luaV_fastgeti(L, t, n, slot)) 800 if (luaV_fastgeti(L, t, n, slot)) {
800 luaV_finishfastset(L, t, slot, L->top - 1); 801 luaV_finishfastset(L, t, slot, L->top - 1);
802 }
801 else { 803 else {
802 TValue aux; 804 TValue aux;
803 setivalue(&aux, n); 805 setivalue(&aux, n);
diff --git a/lvm.c b/lvm.c
index 9cbb9f45..7c15e899 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.284 2017/05/18 19:44:19 roberto Exp roberto $ 2** $Id: lvm.c,v 2.285 2017/05/23 12:50:11 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -916,8 +916,9 @@ void luaV_execute (lua_State *L) {
916 TValue *rb = KB(i); 916 TValue *rb = KB(i);
917 TValue *rc = RKC(i); 917 TValue *rc = RKC(i);
918 TString *key = tsvalue(rb); /* key must be a string */ 918 TString *key = tsvalue(rb); /* key must be a string */
919 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) 919 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
920 luaV_finishfastset(L, upval, slot, rc); 920 luaV_finishfastset(L, upval, slot, rc);
921 }
921 else 922 else
922 Protect(luaV_finishset(L, upval, rb, rc, slot)); 923 Protect(luaV_finishset(L, upval, rb, rc, slot));
923 vmbreak; 924 vmbreak;
@@ -929,8 +930,9 @@ void luaV_execute (lua_State *L) {
929 lua_Unsigned n; 930 lua_Unsigned n;
930 if (ttisinteger(rb) /* fast track for integers? */ 931 if (ttisinteger(rb) /* fast track for integers? */
931 ? (n = ivalue(rb), luaV_fastgeti(L, ra, n, slot)) 932 ? (n = ivalue(rb), luaV_fastgeti(L, ra, n, slot))
932 : luaV_fastget(L, ra, rb, slot, luaH_get)) 933 : luaV_fastget(L, ra, rb, slot, luaH_get)) {
933 luaV_finishfastset(L, ra, slot, rc); 934 luaV_finishfastset(L, ra, slot, rc);
935 }
934 else 936 else
935 Protect(luaV_finishset(L, ra, rb, rc, slot)); 937 Protect(luaV_finishset(L, ra, rb, rc, slot));
936 vmbreak; 938 vmbreak;
@@ -939,8 +941,9 @@ void luaV_execute (lua_State *L) {
939 const TValue *slot; 941 const TValue *slot;
940 int c = GETARG_B(i); 942 int c = GETARG_B(i);
941 TValue *rc = RKC(i); 943 TValue *rc = RKC(i);
942 if (luaV_fastgeti(L, ra, c, slot)) 944 if (luaV_fastgeti(L, ra, c, slot)) {
943 luaV_finishfastset(L, ra, slot, rc); 945 luaV_finishfastset(L, ra, slot, rc);
946 }
944 else { 947 else {
945 TValue key; 948 TValue key;
946 setivalue(&key, c); 949 setivalue(&key, c);
@@ -953,8 +956,9 @@ void luaV_execute (lua_State *L) {
953 TValue *rb = KB(i); 956 TValue *rb = KB(i);
954 TValue *rc = RKC(i); 957 TValue *rc = RKC(i);
955 TString *key = tsvalue(rb); /* key must be a string */ 958 TString *key = tsvalue(rb); /* key must be a string */
956 if (luaV_fastget(L, ra, key, slot, luaH_getshortstr)) 959 if (luaV_fastget(L, ra, key, slot, luaH_getshortstr)) {
957 luaV_finishfastset(L, ra, slot, rc); 960 luaV_finishfastset(L, ra, slot, rc);
961 }
958 else 962 else
959 Protect(luaV_finishset(L, ra, rb, rc, slot)); 963 Protect(luaV_finishset(L, ra, rb, rc, slot));
960 vmbreak; 964 vmbreak;