From b712fba17ccf4c818a2c795e660f9cbbb9c80bfe Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Tue, 28 Apr 2020 12:14:46 +0300 Subject: [PATCH] hickup, re-fix dictEncObjKeyCompare come to think of it, in theory (not in practice), getDecodedObject can return the same original object with refcount incremented, so the pointer comparision in the previous commit was invalid. so now instead of checking the encoding, we explicitly check the refcount. --- src/server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server.c b/src/server.c index 1086dab48..ab6280121 100644 --- a/src/server.c +++ b/src/server.c @@ -1223,11 +1223,11 @@ int dictEncObjKeyCompare(void *privdata, const void *key1, * good reasons, because it would incrRefCount() the object, which * is invalid. So we check to make sure dictFind() works with static * objects as well. */ - if (!sdsEncodedObject(o1)) o1 = getDecodedObject(o1); - if (!sdsEncodedObject(o2)) o2 = getDecodedObject(o2); + if (o1->refcount != OBJ_STATIC_REFCOUNT) o1 = getDecodedObject(o1); + if (o2->refcount != OBJ_STATIC_REFCOUNT) o2 = getDecodedObject(o2); cmp = dictSdsKeyCompare(privdata,o1->ptr,o2->ptr); - if (o1!=key1) decrRefCount(o1); - if (o2!=key2) decrRefCount(o2); + if (o1->refcount != OBJ_STATIC_REFCOUNT) decrRefCount(o1); + if (o2->refcount != OBJ_STATIC_REFCOUNT) decrRefCount(o2); return cmp; }