aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index 06396ad3..661fdb14 100644
--- a/lapi.c
+++ b/lapi.c
@@ -936,8 +936,8 @@ LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) {
936 api_checknelems(L, 1); 936 api_checknelems(L, 1);
937 o = index2value(L, idx); 937 o = index2value(L, idx);
938 api_check(L, ttisfulluserdata(o), "full userdata expected"); 938 api_check(L, ttisfulluserdata(o), "full userdata expected");
939 if (!(0 < n && n <= uvalue(o)->nuvalue)) 939 if (!(cast_uint(n) - 1u < cast_uint(uvalue(o)->nuvalue)))
940 res = 0; 940 res = 0; /* 'n' not in [1, uvalue(o)->nuvalue] */
941 else { 941 else {
942 setobj(L, &uvalue(o)->uv[n - 1].uv, s2v(L->top - 1)); 942 setobj(L, &uvalue(o)->uv[n - 1].uv, s2v(L->top - 1));
943 luaC_barrierback(L, gcvalue(o), s2v(L->top - 1)); 943 luaC_barrierback(L, gcvalue(o), s2v(L->top - 1));
@@ -1313,7 +1313,8 @@ static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1313 switch (ttypetag(fi)) { 1313 switch (ttypetag(fi)) {
1314 case LUA_TCCL: { /* C closure */ 1314 case LUA_TCCL: { /* C closure */
1315 CClosure *f = clCvalue(fi); 1315 CClosure *f = clCvalue(fi);
1316 if (!(1 <= n && n <= f->nupvalues)) return NULL; 1316 if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues)))
1317 return NULL; /* 'n' not in [1, f->nupvalues] */
1317 *val = &f->upvalue[n-1]; 1318 *val = &f->upvalue[n-1];
1318 if (owner) *owner = obj2gco(f); 1319 if (owner) *owner = obj2gco(f);
1319 return ""; 1320 return "";
@@ -1322,7 +1323,8 @@ static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1322 LClosure *f = clLvalue(fi); 1323 LClosure *f = clLvalue(fi);
1323 TString *name; 1324 TString *name;
1324 Proto *p = f->p; 1325 Proto *p = f->p;
1325 if (!(1 <= n && n <= p->sizeupvalues)) return NULL; 1326 if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues)))
1327 return NULL; /* 'n' not in [1, p->sizeupvalues] */
1326 *val = f->upvals[n-1]->v; 1328 *val = f->upvals[n-1]->v;
1327 if (owner) *owner = obj2gco(f->upvals[n - 1]); 1329 if (owner) *owner = obj2gco(f->upvals[n - 1]);
1328 name = p->upvalues[n-1].name; 1330 name = p->upvalues[n-1].name;