mirror of
https://github.com/fluencelabs/redis
synced 2025-07-31 16:31:58 +00:00
getLongLongFromObject: use string2ll() instead of strict_strtoll().
strict_strtoll() has a bug that reports the empty string as ok and parses it as zero. Apparently nobody ever replaced this old call with the faster/saner string2ll() which is used otherwise in the rest of the Redis core. This commit close #3333.
This commit is contained in:
@@ -616,18 +616,13 @@ int getLongDoubleFromObjectOrReply(client *c, robj *o, long double *target, cons
|
||||
|
||||
int getLongLongFromObject(robj *o, long long *target) {
|
||||
long long value;
|
||||
char *eptr;
|
||||
|
||||
if (o == NULL) {
|
||||
value = 0;
|
||||
} else {
|
||||
serverAssertWithInfo(NULL,o,o->type == OBJ_STRING);
|
||||
if (sdsEncodedObject(o)) {
|
||||
errno = 0;
|
||||
value = strtoll(o->ptr, &eptr, 10);
|
||||
if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
|
||||
errno == ERANGE)
|
||||
return C_ERR;
|
||||
if (string2ll(o->ptr,sdslen(o->ptr),&value) == 0) return C_ERR;
|
||||
} else if (o->encoding == OBJ_ENCODING_INT) {
|
||||
value = (long)o->ptr;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user