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 16:46:16 +08:00 committed by GitHub
parent 79db037a4f
commit 08aed7e7dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);