[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[legacy/ecore] ecore-1.7 01/01: ecore_imf: Fix memory leak in scim immodule



jihoon pushed a commit to branch ecore-1.7.

commit 72fe9ed09b48cd291237c1669f4f41c382948e08
Author: Jihoon Kim <jihoon48.kim@samsung.com>
Date:   Fri Sep 13 10:53:01 2013 +0900

    ecore_imf: Fix memory leak in scim immodule
---
 ChangeLog                                     |  4 ++++
 NEWS                                          | 11 +++++++++++
 src/modules/immodules/scim/scim_imcontext.cpp | 14 ++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 85c2e6f..916e5d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1196,3 +1196,7 @@
 2013-08-02  Eduardo Lima (Etrunko)
 
         * 1.7.8 release
+
+2013-09-12  Jihoon Kim (jihoon)
+
+        * ecore_imf: Fix memory leak in scim immodule
diff --git a/NEWS b/NEWS
index b961758..295176d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+Ecore 1.7.9
+
+Changes since Ecore 1.7.8:
+--------------------------
+Additions:
+
+Deprecations:
+
+Fixes:
+    * ecore_imf: Fix memory leak in scim immodule
+
 Ecore 1.7.8
 
 Changes since Ecore 1.7.7:
diff --git a/src/modules/immodules/scim/scim_imcontext.cpp b/src/modules/immodules/scim/scim_imcontext.cpp
index d4d20b1..64d1ebc 100644
--- a/src/modules/immodules/scim/scim_imcontext.cpp
+++ b/src/modules/immodules/scim/scim_imcontext.cpp
@@ -2818,8 +2818,22 @@ slot_get_surrounding_text(IMEngineInstanceBase *si,
           {
              SCIM_DEBUG_FRONTEND(2) << "Surrounding text: " << surrounding <<"\n";
              SCIM_DEBUG_FRONTEND(2) << "Cursor Index    : " << cursor_index <<"\n";
+             if (!surrounding)
+               return false;
+
+             if (cursor_index < 0)
+               {
+                  free(surrounding);
+                  surrounding = NULL;
+                  return false;
+               }
+
              WideString before(utf8_mbstowcs(String(surrounding, surrounding + cursor_index)));
              WideString after(utf8_mbstowcs(String(surrounding + cursor_index)));
+
+             free(surrounding);
+             surrounding = NULL;
+
              if (maxlen_before > 0 && ((unsigned int)maxlen_before) < before.length())
                before = WideString(before.begin() + (before.length() - maxlen_before), before.end());
              else if (maxlen_before == 0) before = WideString();

--