aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-02-12 11:34:12 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-02-12 11:34:12 -0200
commit3deb38814df08d05dbdc99af15b0ed8dec4301ca (patch)
treef7d8e178853ee66b16eaf73add17a2cf839d0b8e /lapi.c
parent3b5b14a0852a911a299d97c91e09da52f66ea23d (diff)
downloadlua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.tar.gz
lua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.tar.bz2
lua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.zip
added assertions checking maximum number of upvalues
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index a33fa761..2c725bed 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.62 2007/11/28 18:27:38 roberto Exp roberto $ 2** $Id: lapi.c,v 2.63 2008/01/25 13:42:12 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*/
@@ -64,6 +64,7 @@ static TValue *index2adr (lua_State *L, int idx) {
64 default: { 64 default: {
65 Closure *func = curr_func(L); 65 Closure *func = curr_func(L);
66 idx = LUA_GLOBALSINDEX - idx; 66 idx = LUA_GLOBALSINDEX - idx;
67 api_check(L, idx <= UCHAR_MAX + 1);
67 return (idx <= func->c.nupvalues) 68 return (idx <= func->c.nupvalues)
68 ? &func->c.upvalue[idx-1] 69 ? &func->c.upvalue[idx-1]
69 : cast(TValue *, luaO_nilobject); 70 : cast(TValue *, luaO_nilobject);
@@ -465,8 +466,9 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
465LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { 466LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
466 Closure *cl; 467 Closure *cl;
467 lua_lock(L); 468 lua_lock(L);
468 luaC_checkGC(L);
469 api_checknelems(L, n); 469 api_checknelems(L, n);
470 api_check(L, n <= UCHAR_MAX);
471 luaC_checkGC(L);
470 cl = luaF_newCclosure(L, n, getcurrenv(L)); 472 cl = luaF_newCclosure(L, n, getcurrenv(L));
471 cl->c.f = fn; 473 cl->c.f = fn;
472 L->top -= n; 474 L->top -= n;