diff --git a/src/scripting.c b/src/scripting.c index 7880d1b0e..3fc804a96 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -790,6 +790,10 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { return raise_error ? luaRaiseError(lua) : 1; } + /* Pop all arguments from the stack, we do not need them anymore + * and this way we guaranty we will have room on the stack for the result. */ + lua_pop(lua, argc); + /* Setup our fake client for command execution */ c->argv = argv; c->argc = argc; diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 9fbf7e41d..be7147d35 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -622,6 +622,16 @@ start_server {tags {"scripting"}} { # make sure the connection is still valid assert_equal [r ping] {PONG} } + + test {Script check unpack with massive arguments} { + r eval { + local a = {} + for i=1,7999 do + a[i] = 1 + end + return redis.call("lpush", "l", unpack(a)) + } 0 + } {7999} } # Start a new server since the last test in this stanza will kill the