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