summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2018-02-13 15:50:21 +0100
committerGitHub <noreply@github.com>2018-02-13 15:50:21 +0100
commitf9e6c2046feadcd284bdb68de4f49296f91bbe53 (patch)
tree189e1a935bae5249c0a5466e443fc39e366dfde1
parentc14ba46e3a725a2325d8d5fd90097b1c889de1e2 (diff)
parent89a9e5a9a2dba7bcdb4ef32fa73f105a14923c1a (diff)
downloadredis-f9e6c2046feadcd284bdb68de4f49296f91bbe53.tar.gz
Merge pull request #3745 from guybe7/unstable
enlarged buffer given to ld2string
-rw-r--r--src/object.c2
-rw-r--r--src/t_hash.c2
-rw-r--r--src/util.h5
3 files changed, 7 insertions, 2 deletions
diff --git a/src/object.c b/src/object.c
index 3305d944e..395ec84df 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);