mirror of
https://github.com/fluencelabs/redis
synced 2025-06-15 10:11:21 +00:00
Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE and ZINTERSTORE.
This commit is contained in:
@ -1548,6 +1548,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
double score, value;
|
double score, value;
|
||||||
|
|
||||||
score = src[0].weight * zval.score;
|
score = src[0].weight * zval.score;
|
||||||
|
if (isnan(score)) score = 0;
|
||||||
|
|
||||||
for (j = 1; j < setnum; j++) {
|
for (j = 1; j < setnum; j++) {
|
||||||
/* It is not safe to access the zset we are
|
/* It is not safe to access the zset we are
|
||||||
* iterating, so explicitly check for equal object. */
|
* iterating, so explicitly check for equal object. */
|
||||||
@ -1590,6 +1592,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
|
|
||||||
/* Initialize score */
|
/* Initialize score */
|
||||||
score = src[i].weight * zval.score;
|
score = src[i].weight * zval.score;
|
||||||
|
if (isnan(score)) score = 0;
|
||||||
|
|
||||||
/* Because the inputs are sorted by size, it's only possible
|
/* Because the inputs are sorted by size, it's only possible
|
||||||
* for sets at larger indices to hold this element. */
|
* for sets at larger indices to hold this element. */
|
||||||
|
Reference in New Issue
Block a user