Skip to content

Commit

Permalink
Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE…
Browse files Browse the repository at this point in the history
… and ZINTERSTORE.
  • Loading branch information
antirez committed Dec 23, 2011
1 parent 2e68921 commit 0692d06
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/t_zset.c
Expand Up @@ -1548,6 +1548,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
double score, value;

score = src[0].weight * zval.score;
if (isnan(score)) score = 0;

for (j = 1; j < setnum; j++) {
/* It is not safe to access the zset we are
* iterating, so explicitly check for equal object. */
Expand Down Expand Up @@ -1590,6 +1592,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {

/* Initialize score */
score = src[i].weight * zval.score;
if (isnan(score)) score = 0;

/* Because the inputs are sorted by size, it's only possible
* for sets at larger indices to hold this element. */
Expand Down

0 comments on commit 0692d06

Please sign in to comment.