From ee112641f62ddb12d5c9d744261a6cd10db1f3c0 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Fri, 19 Nov 2010 02:49:42 -0800 Subject: [PATCH] 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 --- apps/Term/jni/termExec.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/Term/jni/termExec.cpp b/apps/Term/jni/termExec.cpp index d0666cc91..a1edc95e4 100644 --- a/apps/Term/jni/termExec.cpp +++ b/apps/Term/jni/termExec.cpp @@ -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];