From: antirez Date: Fri, 23 Dec 2011 08:27:31 +0000 (+0100) Subject: Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE and ZINTERSTORE. X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/256356ffd83b93abe49911a4b4bae020d5149348 Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE and ZINTERSTORE. --- diff --git a/src/t_zset.c b/src/t_zset.c index 7008f0c4..f42e5a31 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1545,6 +1545,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. */ @@ -1587,6 +1589,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. */