From 386fdad6820fefa77355ed330f3072a5e2a4bd3e Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Wed, 10 Aug 2011 19:39:52 +0930 Subject: Fix detection of objects with numeric string keys lua_array_length() recognised some objects with numeric string keys as arrays since it was incorrectly using lua_isnumber(). When an object was incorrectly recognised as an array, json_append_array() would not find any entries and generate a result like: [null,null,...] Reported by: Zhang "agentzh" Yichun --- lua_cjson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua_cjson.c') diff --git a/lua_cjson.c b/lua_cjson.c index 4b1915a..b46e915 100644 --- a/lua_cjson.c +++ b/lua_cjson.c @@ -501,7 +501,7 @@ static int lua_array_length(lua_State *l, json_config_t *cfg) /* table, startkey */ while (lua_next(l, -2) != 0) { /* table, key, value */ - if (lua_isnumber(l, -2) && + if (lua_type(l, -2) == LUA_TNUMBER && (k = lua_tonumber(l, -2))) { /* Integer >= 1 ? */ if (floor(k) == k && k >= 1) { -- cgit v1.2.3-55-g6feb