diff options
| -rw-r--r-- | lapi.c | 15 |
1 files changed, 10 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.231 2003/02/24 16:54:20 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.232 2003/02/27 12:33:07 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 | */ |
| @@ -56,8 +56,10 @@ static TObject *negindex (lua_State *L, int idx) { | |||
| 56 | default: { | 56 | default: { |
| 57 | TObject *func = (L->base - 1); | 57 | TObject *func = (L->base - 1); |
| 58 | idx = LUA_GLOBALSINDEX - idx; | 58 | idx = LUA_GLOBALSINDEX - idx; |
| 59 | api_check(L, iscfunction(func) && idx <= clvalue(func)->c.nupvalues); | 59 | lua_assert(iscfunction(func)); |
| 60 | return &clvalue(func)->c.upvalue[idx-1]; | 60 | return (idx <= clvalue(func)->c.nupvalues) |
| 61 | ? &clvalue(func)->c.upvalue[idx-1] | ||
| 62 | : NULL; | ||
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| 63 | } | 65 | } |
| @@ -68,8 +70,11 @@ static TObject *luaA_index (lua_State *L, int idx) { | |||
| 68 | api_check(L, idx <= L->top - L->base); | 70 | api_check(L, idx <= L->top - L->base); |
| 69 | return L->base + idx - 1; | 71 | return L->base + idx - 1; |
| 70 | } | 72 | } |
| 71 | else | 73 | else { |
| 72 | return negindex(L, idx); | 74 | TObject *o = negindex(L, idx); |
| 75 | api_check(L, o != NULL); | ||
| 76 | return o; | ||
| 77 | } | ||
| 73 | } | 78 | } |
| 74 | 79 | ||
| 75 | 80 | ||
