]> git.saurik.com Git - redis.git/commitdiff
check object type in lookupKeyByPattern
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 16 Apr 2010 11:37:40 +0000 (13:37 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 16 Apr 2010 11:37:40 +0000 (13:37 +0200)
redis.c

diff --git a/redis.c b/redis.c
index 76f28578c54c749024aa9a4af2e5262510ee29c6..ee9eccfb148417d740f45c2fa72d69331caf8f33 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -6533,6 +6533,10 @@ static robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
         initStaticStringObject(fieldobj,((char*)&fieldname)+(sizeof(long)*2));
         o = hashGet(o, &fieldobj);
     } else {
+        if (o->type != REDIS_STRING) {
+            return NULL;
+        }
+
         /* Every object that this function returns needs to have its refcount
          * increased. sortCommand decreases it again. */
         incrRefCount(o);
@@ -6707,10 +6711,6 @@ static void sortCommand(redisClient *c) {
                 /* lookup value to sort by */
                 byval = lookupKeyByPattern(c->db,sortby,vector[j].obj);
                 if (!byval) continue;
-                if (byval->type != REDIS_STRING) {
-                    decrRefCount(byval);
-                    continue;
-                }
             } else {
                 /* use object itself to sort by */
                 byval = vector[j].obj;