From 50aa987a02fd77557e62b70cd4c6ef4e55b437d6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 4 Aug 2021 11:24:57 +0100 Subject: [PATCH] Fix a memory leak in the string class Signed-off-by: falkTX --- distrho/extra/String.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index c1ec9809..fe3d9936 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -59,12 +59,12 @@ public: /* * Simple char string. */ - explicit String(char* const strBuf, const bool copyData = true) noexcept + explicit String(char* const strBuf, const bool reallocData = true) noexcept : fBuffer(_null()), fBufferLen(0), fBufferAlloc(false) { - if (copyData || strBuf == nullptr) + if (reallocData || strBuf == nullptr) { _dup(strBuf); } @@ -930,7 +930,7 @@ String operator+(const String& strBefore, const char* const strBufAfter) noexcep std::memcpy(newBuf, strBefore.buffer(), strBeforeLen); std::memcpy(newBuf + strBeforeLen, strBufAfter, strBufAfterLen + 1); - return String(newBuf); + return String(newBuf, false); } static inline @@ -950,7 +950,7 @@ String operator+(const char* const strBufBefore, const String& strAfter) noexcep std::memcpy(newBuf, strBufBefore, strBufBeforeLen); std::memcpy(newBuf + strBufBeforeLen, strAfter.buffer(), strAfterLen + 1); - return String(newBuf); + return String(newBuf, false); } // -----------------------------------------------------------------------