aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/str.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/str.cpp b/common/str.cpp
index c5616baf52..0940d50bdc 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -265,10 +265,12 @@ void String::ensureCapacity(int new_len, bool keep_old) {
char *newStr = (char *)malloc(newCapacity+1);
- if (keep_old && _str)
+ if (keep_old && _str) {
memcpy(newStr, _str, _len + 1);
- else
+ } else {
_len = 0;
+ newStr[0] = 0;
+ }
decRefCount();
_refCount = 0;