diff options
author | Guy Benoish <guy.benoish@redislabs.com> | 2017-01-11 19:24:19 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-02-13 15:51:36 +0100 |
commit | a64f36e5562afedb76dbb13d602f840aa6c39681 (patch) | |
tree | 76e7e51d0197036b588c4f99f2ec6af2c7fcd82c | |
parent | f1705801951775288766a3a2374ee2a802575da7 (diff) | |
download | redis-a64f36e5562afedb76dbb13d602f840aa6c39681.tar.gz |
enlarged buffer given to ld2string
-rw-r--r-- | src/object.c | 2 | ||||
-rw-r--r-- | src/t_hash.c | 2 | ||||
-rw-r--r-- | src/util.h | 5 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/object.c b/src/object.c index 910410b05..4e3080f73 100644 --- a/src/object.c +++ b/src/object.c @@ -145,7 +145,7 @@ robj *createStringObjectFromLongLong(long long value) { * * The 'humanfriendly' option is used for INCRBYFLOAT and HINCRBYFLOAT. */ robj *createStringObjectFromLongDouble(long double value, int humanfriendly) { - char buf[256]; + char buf[MAX_LONG_DOUBLE_CHARS]; int len = ld2string(buf,sizeof(buf),value,humanfriendly); return createStringObject(buf,len); } diff --git a/src/t_hash.c b/src/t_hash.c index be73932c5..fa3a893a6 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -616,7 +616,7 @@ void hincrbyfloatCommand(client *c) { value += incr; - char buf[256]; + char buf[MAX_LONG_DOUBLE_CHARS]; int len = ld2string(buf,sizeof(buf),value,1); new = sdsnewlen(buf,len); hashTypeSet(o,c->argv[2]->ptr,new,HASH_SET_TAKE_VALUE); diff --git a/src/util.h b/src/util.h index d7784495b..91acde047 100644 --- a/src/util.h +++ b/src/util.h @@ -33,6 +33,11 @@ #include <stdint.h> #include "sds.h" +/* The maximum number of characters needed to represent a long double + * as a string (long double has a huge range). + * This should be the size of the buffer given to ld2string */ +#define MAX_LONG_DOUBLE_CHARS 5*1024 + int stringmatchlen(const char *p, int plen, const char *s, int slen, int nocase); int stringmatch(const char *p, const char *s, int nocase); long long memtoll(const char *p, int *err); |