From 58b1bda0d94b131044fcb6838f660decb1902467 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 21 Nov 2022 19:26:16 +0800 Subject: [PATCH] first key can't can be in hash part, see #1484 --- lualib-src/lua-bson.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lualib-src/lua-bson.c b/lualib-src/lua-bson.c index 28414d51..29d6c70c 100644 --- a/lualib-src/lua-bson.c +++ b/lualib-src/lua-bson.c @@ -519,7 +519,10 @@ is_rawarray(lua_State *L) { } lua_Integer firstkey = lua_isinteger(L, -2) ? lua_tointeger(L, -2) : 0; lua_pop(L, 2); - return firstkey > 0; + if (firstkey <= 1) { + return firstkey > 0; + } + return firstkey <= lua_rawlen(L, -1); } static void