commit 50aa987a02fd77557e62b70cd4c6ef4e55b437d6
parent 6125f48a680853d6a203738eec4b3670fa1929d6
Author: falkTX <falktx@falktx.com>
Date: Wed, 4 Aug 2021 11:24:30 +0100
Fix a memory leak in the string class
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git 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);
}
// -----------------------------------------------------------------------