mirror of
https://github.com/fluencelabs/redis
synced 2025-06-23 22:11:33 +00:00
Fixed ZINCR Nan bugs leading to server crash and added tests
This commit is contained in:
14
redis.c
14
redis.c
@ -5710,6 +5710,11 @@ static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scor
|
||||
zset *zs;
|
||||
double *score;
|
||||
|
||||
if (isnan(scoreval)) {
|
||||
addReplySds(c,sdsnew("-ERR provide score is Not A Number (nan)\r\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
zsetobj = lookupKeyWrite(c->db,key);
|
||||
if (zsetobj == NULL) {
|
||||
zsetobj = createZsetObject();
|
||||
@ -5738,6 +5743,15 @@ static void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double scor
|
||||
} else {
|
||||
*score = scoreval;
|
||||
}
|
||||
if (isnan(*score)) {
|
||||
addReplySds(c,
|
||||
sdsnew("-ERR resulting score is Not A Number (nan)\r\n"));
|
||||
zfree(score);
|
||||
/* Note that we don't need to check if the zset may be empty and
|
||||
* should be removed here, as we can only obtain Nan as score if
|
||||
* there was already an element in the sorted set. */
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
*score = scoreval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user