summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua/lapi.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lua/lapi.c b/src/lua/lapi.c
index 7be0ebfe..b597e00a 100644
--- a/src/lua/lapi.c
+++ b/src/lua/lapi.c
@@ -40,12 +40,17 @@ TObject *luaA_index (lua_State *L, int index) {
static TObject *luaA_indexAcceptable (lua_State *L, int index) {
- if (index >= 0) {
+ if (index == 0) {
+ return NULL;
+ } else if (index > 0) {
TObject *o = L->Cbase+(index-1);
if (o >= L->top) return NULL;
else return o;
+ } else {
+ TObject *o = L->top+index;
+ if(o < L->Cbase) return NULL;
+ else return o;
}
- else return L->top+index;
}