Permalink
Browse files

Fixed bug introduced with the copy-on-write friendly iteartor

  • Loading branch information...
antirez committed May 13, 2011
1 parent cc8a0f8 commit 430719ca53dfe1cb6f5c0ecaa6db92e117c89e77
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/t_zset.c
View
@@ -686,7 +686,18 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
score = src[0].weight * zunionInterDictValue(de);
for (j = 1; j < setnum; j++) {
- dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));
+ dictEntry *other;
+
+ /* If it's the same dictionary don't lookup as we are not
+ * in the context of a safe iterator. It's the same
+ * dictionary so we are sure the element is inside.
+ * This happens on SINTERSTORE dest 2 mykey mykey. */
+ if (src[j].dict == src[0].dict) {
+ other = de;
+ } else {
+ other = dictFind(src[j].dict,dictGetEntryKey(de));
+ }
+
if (other) {
value = src[j].weight * zunionInterDictValue(other);
zunionInterAggregate(&score,value,aggregate);

0 comments on commit 430719c

Please sign in to comment.