luaa: check that object is a table before calling lua_next()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-12-09 16:45:02 +01:00
parent 3af636c3e6
commit 3d2c205969
2 changed files with 6 additions and 6 deletions

5
luaa.c
View File

@ -295,8 +295,9 @@ luaA_next(lua_State *L, int idx)
}
return 1;
}
return lua_next(L, idx);
else if(lua_istable(L, idx))
return lua_next(L, idx);
return 0;
}
/** Generic pairs function.

View File

@ -716,14 +716,14 @@ wibox_widgets_table_build(lua_State *L, wibox_t *wibox)
static bool
luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
{
bool ret = false;
fprintf(stderr, "look for %p\n", item);
if(wibox->widgets_table != LUA_REFNIL)
{
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, wibox->widgets_table);
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
ret = true;
return true;
}
return ret;
return false;
}
/** Invalidate a wibox by a Lua object (table, etc).
@ -755,7 +755,6 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
}
}
/** Wibox object.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.