summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-07-06 11:43:33 +0200
committerantirez <antirez@gmail.com>2016-07-06 11:47:07 +0200
commit21736b41a2e74952dde9d535353a83b94c9b29c2 (patch)
treedaf1c7a628e4de63789cdd987383fd658ccfbc38
parent0b748e9139ac16d38380f5b51f78d3dd398254e8 (diff)
downloadredis-21736b41a2e74952dde9d535353a83b94c9b29c2.tar.gz
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.
-rw-r--r--src/object.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/object.c b/src/object.c
index 04e41b5c8..22d222230 100644
--- a/src/object.c
+++ b/src/object.c
@@ -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 {