Skip to content

Commit b712fba

Browse files
oranagraantirez
authored andcommitted
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.
1 parent ea63aea commit b712fba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/server.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,11 @@ int dictEncObjKeyCompare(void *privdata, const void *key1,
12231223
* good reasons, because it would incrRefCount() the object, which
12241224
* is invalid. So we check to make sure dictFind() works with static
12251225
* objects as well. */
1226-
if (!sdsEncodedObject(o1)) o1 = getDecodedObject(o1);
1227-
if (!sdsEncodedObject(o2)) o2 = getDecodedObject(o2);
1226+
if (o1->refcount != OBJ_STATIC_REFCOUNT) o1 = getDecodedObject(o1);
1227+
if (o2->refcount != OBJ_STATIC_REFCOUNT) o2 = getDecodedObject(o2);
12281228
cmp = dictSdsKeyCompare(privdata,o1->ptr,o2->ptr);
1229-
if (o1!=key1) decrRefCount(o1);
1230-
if (o2!=key2) decrRefCount(o2);
1229+
if (o1->refcount != OBJ_STATIC_REFCOUNT) decrRefCount(o1);
1230+
if (o2->refcount != OBJ_STATIC_REFCOUNT) decrRefCount(o2);
12311231
return cmp;
12321232
}
12331233

0 commit comments

Comments
 (0)