Skip to content

Commit

Permalink
Fixed misuse of the new iterator semantics in ZUNIONSTORE
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed May 15, 2011
1 parent d070abe commit cb16b6c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/t_zset.c
Expand Up @@ -1521,6 +1521,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {

score = src[0].weight * zval.score;
for (j = 1; j < setnum; j++) {
/* It is not safe to access the hash we zset we are
* iterating, so explicitly check for equal object. */
if (src[j].subject == src[0].subject) {
value = zval.score*src[j].weight;
zunionInterAggregate(&score,value,aggregate);
Expand Down Expand Up @@ -1564,7 +1566,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
/* Because the inputs are sorted by size, it's only possible
* for sets at larger indices to hold this element. */
for (j = (i+1); j < setnum; j++) {
if (zuiFind(&src[j],&zval,&value)) {
/* It is not safe to access the hash we zset we are
* iterating, so explicitly check for equal object. */
if(src[j].subject == src[i].subject) {
value = zval.score*src[j].weight;
zunionInterAggregate(&score,value,aggregate);
} else if (zuiFind(&src[j],&zval,&value)) {
value *= src[j].weight;
zunionInterAggregate(&score,value,aggregate);
}
Expand Down

0 comments on commit cb16b6c

Please sign in to comment.