diff --git a/deps/lua/src/lua_cjson.c b/deps/lua/src/lua_cjson.c index 991f5d31dd..b86d73e97c 100644 --- a/deps/lua/src/lua_cjson.c +++ b/deps/lua/src/lua_cjson.c @@ -464,9 +464,8 @@ static void json_encode_exception(lua_State *l, json_config_t *cfg, strbuf_t *js static void json_append_string(lua_State *l, strbuf_t *json, int lindex) { const char *escstr; - int i; const char *str; - size_t len; + size_t i, len; str = lua_tolstring(l, lindex, &len); diff --git a/deps/lua/src/strbuf.c b/deps/lua/src/strbuf.c index 775e8baf1b..97ee940c90 100644 --- a/deps/lua/src/strbuf.c +++ b/deps/lua/src/strbuf.c @@ -176,8 +176,7 @@ void strbuf_resize(strbuf_t *s, size_t len) void strbuf_append_string(strbuf_t *s, const char *str) { - int i; - size_t space; + size_t i, space; space = strbuf_empty_length(s); diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index a8195fb915..cedf2b4f7c 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -307,6 +307,13 @@ start_server {tags {"scripting"}} { set e } {*against a key*} + test {EVAL - JSON string encoding a string larger than 2GB} { + run_script { + local s = string.rep("a", 1024 * 1024 * 1024) + return #cjson.encode(s..s..s) + } 0 + } {3221225474} {large-memory} ;# length includes two double quotes at both ends + test {EVAL - JSON numeric decoding} { # We must return the table as a string because otherwise # Redis converts floats to ints and we get 0 and 1023 instead