summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-12-23 09:27:31 +0100
committerantirez <antirez@gmail.com>2011-12-23 09:28:51 +0100
commit0692d060b3d374bb3bb4e2b48b55c2ad98276660 (patch)
treef197db529c5ae8c40b80a65c7e7be85e79a78bc1
parent2e689217d5c11125f3153aa7680411f44f09c3b4 (diff)
downloadredis-0692d060b3d374bb3bb4e2b48b55c2ad98276660.tar.gz
Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE and ZINTERSTORE.
-rw-r--r--src/t_zset.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/t_zset.c b/src/t_zset.c
index ea0bfdea0..902d61493 100644
--- a/src/t_zset.c
+++ b/src/t_zset.c
@@ -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. */
@@ -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. */