diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index 8a34e981..b7fda927 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2025 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -1030,13 +1030,14 @@ public: } // we have some data ourselves, reallocate to add the new stuff - char* const newBuf = static_cast(std::realloc(fBuffer, fBufferLen + strBufLen + 1)); + char* const newBuf = static_cast(std::realloc(fBufferAlloc ? fBuffer : nullptr, fBufferLen + strBufLen + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, *this); std::memcpy(newBuf + fBufferLen, strBuf, strBufLen + 1); fBuffer = newBuf; fBufferLen += strBufLen; + fBufferAlloc = true; return *this; }