From: Pieter Noordhuis Date: Wed, 23 Feb 2011 08:39:29 +0000 (+0100) Subject: Restore argc/argv in EXEC after command is executed X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/6c682e559cd250049ce483d60af19a42d0177d72 Restore argc/argv in EXEC after command is executed --- diff --git a/src/multi.c b/src/multi.c index 59fc9d9e..ba3a0cd6 100644 --- a/src/multi.c +++ b/src/multi.c @@ -110,6 +110,10 @@ void execCommand(redisClient *c) { c->argc = c->mstate.commands[j].argc; c->argv = c->mstate.commands[j].argv; call(c,c->mstate.commands[j].cmd); + + /* Commands may alter argc/argv, restore mstate. */ + c->mstate.commands[j].argc = c->argc; + c->mstate.commands[j].argv = c->argv; } c->argv = orig_argv; c->argc = orig_argc; diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index f30505d1..716d6897 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -183,6 +183,13 @@ start_server {tags {"other"}} { set _ $err } {*ERR MULTI*} + test {MULTI where commands alter argc/argv} { + r sadd myset a + r multi + r spop myset + list [r exec] [r exists myset] + } {a 0} + test {WATCH inside MULTI is not allowed} { set err {} r multi