From f56f78d15932ea219cfe62e7d07f17034b11a504 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 5 Nov 2013 12:16:29 +0100 Subject: [PATCH] HSCAN/ZSCAN: skip value when matching. This fixes issue #1360 and #1362. --- src/db.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/db.c b/src/db.c index 2115515c..71b639a5 100644 --- a/src/db.c +++ b/src/db.c @@ -505,11 +505,16 @@ void scanGenericCommand(redisClient *c, robj *o) { if (filter) { decrRefCount(kobj); listDelNode(keys, node); - /* Also remove the value for hashes and sorted sets. */ - if (o && (o->type == REDIS_ZSET || o->type == REDIS_HASH)) { - node = nextnode; + } + + /* If this is an hash or a sorted set, we have a flat list of + * key-value elements, so if this element was filtered, remove the + * value, or skip it if it was not filtered: we only match keys. */ + if (o && (o->type == REDIS_ZSET || o->type == REDIS_HASH)) { + node = nextnode; + nextnode = listNextNode(node); + if (filter) { kobj = listNodeValue(node); - nextnode = listNextNode(node); decrRefCount(kobj); listDelNode(keys, node); }