Change getDoubleFromObject to fail on NaN.

Return an error when the resulting value is not a number (NaN). Fix
ZUNIONSTORE/ZINTERSTORE to clean up when a weight argument is not a
double value.
This commit is contained in:
Pieter Noordhuis
2010-07-29 22:13:31 +02:00
parent d9e28bcf00
commit 673e1fb7e4
3 changed files with 31 additions and 27 deletions

View File

@ -1,5 +1,6 @@
#include "redis.h"
#include <pthread.h>
#include <math.h>
robj *createObject(int type, void *ptr) {
robj *o;
@ -319,7 +320,7 @@ int getDoubleFromObject(robj *o, double *target) {
redisAssert(o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
value = strtod(o->ptr, &eptr);
if (eptr[0] != '\0') return REDIS_ERR;
if (eptr[0] != '\0' || isnan(value)) return REDIS_ERR;
} else if (o->encoding == REDIS_ENCODING_INT) {
value = (long)o->ptr;
} else {