From 5b864617bc50dbfc34dcc3393b78b3d07e0f291b Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 10 Mar 2014 16:39:07 +0100 Subject: [PATCH] Cluster: make sortGetKeys() able to handle multiple STORE options. It does not make sense to pass multiple store options, so, better to handle it ;-) --- src/db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index 8bb6df67..950ebe4f 100644 --- a/src/db.c +++ b/src/db.c @@ -1064,7 +1064,10 @@ int *sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) i += skiplist[j].skip; break; } else if (!strcasecmp(argv[i]->ptr,"store") && i+1 < argc) { - keys[num++] = i+1; /* */ + /* Note: we don't increment "num" here and continue the loop + * to be sure to process the *last* "STORE" option if multiple + * ones are provided. This is same behavior as SORT. */ + keys[num] = i+1; /* */ break; } }