Fix potential memory leak in String8::set

Not an actual leak at the moment, since no clients call set more than
once, but you never know how a class might be used in the future.

Change-Id: I601bad02eb16d522af3216ef903a190741444e4c
This commit is contained in:
Jack Palevich
2010-11-19 02:49:42 -08:00
parent b25792a37a
commit ee112641f6

View File

@@ -64,6 +64,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];