From 6ddacdb24dff2b41c3a54d6880e9e0f81e046074 Mon Sep 17 00:00:00 2001 From: Paul Chambers Date: Tue, 1 Aug 2023 18:08:33 -0700 Subject: [PATCH] minor code simplification after overflow bug fix. --- daemon/util/NString.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/daemon/util/NString.cpp b/daemon/util/NString.cpp index 000b6cc3..0cb5a351 100644 --- a/daemon/util/NString.cpp +++ b/daemon/util/NString.cpp @@ -154,10 +154,9 @@ void CString::AppendFmtV(const char* format, va_list ap) if (addLen < 0) return; // error int curLen = Length(); - int newLen = curLen + addLen; - m_data = (char*)realloc(m_data, newLen + 1); + m_data = (char*)realloc(m_data, curLen + addLen + 1); - vsnprintf(m_data + curLen, newLen - curLen + 1, format, ap2); + vsnprintf(m_data + curLen, addLen + 1, format, ap2); va_end(ap2); }