Fix an off by one error in zzlStrtod (#10465)

When vlen = sizeof(buf), the statement buf[vlen] = '\0' accessing the buffer buf is an off by one error.
This commit is contained in:
yiyuaner
2022-03-22 10:46:16 +02:00
committed by GitHub
parent 79db037a4f
commit 08aed7e7dd
+2 -2
View File
@@ -721,8 +721,8 @@ zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) {
double zzlStrtod(unsigned char *vstr, unsigned int vlen) {
char buf[128];
if (vlen > sizeof(buf))
vlen = sizeof(buf);
if (vlen > sizeof(buf) - 1)
vlen = sizeof(buf) - 1;
memcpy(buf,vstr,vlen);
buf[vlen] = '\0';
return strtod(buf,NULL);