diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-12 11:34:12 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-12 11:34:12 -0200 |
| commit | 3deb38814df08d05dbdc99af15b0ed8dec4301ca (patch) | |
| tree | f7d8e178853ee66b16eaf73add17a2cf839d0b8e | |
| parent | 3b5b14a0852a911a299d97c91e09da52f66ea23d (diff) | |
| download | lua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.tar.gz lua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.tar.bz2 lua-3deb38814df08d05dbdc99af15b0ed8dec4301ca.zip | |
added assertions checking maximum number of upvalues
| -rw-r--r-- | lapi.c | 6 |
1 files changed, 4 insertions, 2 deletions
| @@ -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, ...) { | |||
| 465 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | 466 | LUA_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; |
