From 91df781351d3a0f523528f14b4c5e4af10cb125d Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 16 Sep 2022 21:22:21 +0000 Subject: [PATCH] Fix off-by-one error: need 1 more byte for null terminator --- charpool.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charpool.cc b/charpool.cc index 6f3218b43..39427058f 100644 --- a/charpool.cc +++ b/charpool.cc @@ -113,7 +113,7 @@ const char *CharPool::dup(const char *src, int len) { if ((modulus = sz % ALIGN_ON)) sz += ALIGN_ON - modulus; - while (nexti + sz > currentbucketsz) { + while (nexti + sz > currentbucketsz - 1) { /* Doh! We've got to make room */ currentbucketsz <<= 1; nexti = 0; @@ -121,7 +121,7 @@ const char *CharPool::dup(const char *src, int len) { buckets.push_back(p); } - nexti += sz; + nexti += sz + 1; p[sz] = '\0'; return (const char *) memcpy(p, src, sz); }