Commit 21736b41 authored by antirez's avatar antirez
Browse files

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.
parent 0b748e91
...@@ -616,18 +616,13 @@ int getLongDoubleFromObjectOrReply(client *c, robj *o, long double *target, cons ...@@ -616,18 +616,13 @@ int getLongDoubleFromObjectOrReply(client *c, robj *o, long double *target, cons
int getLongLongFromObject(robj *o, long long *target) { int getLongLongFromObject(robj *o, long long *target) {
long long value; long long value;
char *eptr;
if (o == NULL) { if (o == NULL) {
value = 0; value = 0;
} else { } else {
serverAssertWithInfo(NULL,o,o->type == OBJ_STRING); serverAssertWithInfo(NULL,o,o->type == OBJ_STRING);
if (sdsEncodedObject(o)) { if (sdsEncodedObject(o)) {
errno = 0; if (string2ll(o->ptr,sdslen(o->ptr),&value) == 0) return C_ERR;
value = strtoll(o->ptr, &eptr, 10);
if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
errno == ERANGE)
return C_ERR;
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr; value = (long)o->ptr;
} else { } else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment