diff --git a/system/jlib/jstring.cpp b/system/jlib/jstring.cpp index a99f695da10..047fa80ebc6 100644 --- a/system/jlib/jstring.cpp +++ b/system/jlib/jstring.cpp @@ -1071,17 +1071,10 @@ StringBuffer & StringBuffer::replaceString(const char* oldStr, const char* newSt { if (memcmp(buffer, oldStr, oldlen) == 0) { - if (newlen <= curLen) - { - memmove(buffer, newStr, newlen); - curLen = newlen; - } - else - { + if (newlen > curLen) ensureCapacity(newlen); - memcpy(buffer, newStr, newlen); - curLen = newlen; - } + memcpy(buffer, newStr, newlen); + curLen = newlen; } } else