diff --git a/lualib-src/lua-bson.c b/lualib-src/lua-bson.c index 517fd40e..2bdd6d9e 100644 --- a/lualib-src/lua-bson.c +++ b/lualib-src/lua-bson.c @@ -518,7 +518,7 @@ is_rawarray(lua_State *L) { // empty table return false; } - lua_Integer firstkey = lua_tointeger(L, -2); + lua_Integer firstkey = (lua_type(L, -2) == LUA_TNUMBER) ? lua_tointeger(L, -2) : 0; lua_pop(L, 2); if (firstkey != 1) return false;