Avoid potential memory leak in String8::set

(Not an actual memory leak because the current clients of String8
never call set more than once for the same object. But you never
know who might use String8 in the future.)
This commit is contained in:
Jack Palevich 2010-11-19 02:28:02 -08:00
parent 324112b60a
commit 7988d5c035

View File

@ -67,6 +67,9 @@ public:
}
void set(const char16_t* o, size_t numChars) {
if (mString) {
free(mString);
}
mString = (char*) malloc(numChars + 1);
for (size_t i = 0; i < numChars; i++) {
mString[i] = (char) o[i];