jihoon pushed a commit to branch master.

commit 6ff49dbc706f7896960227d18fe35b1d743cc359
Author: Jihoon Kim <[email protected]>
Date:   Thu Sep 12 11:49:06 2013 +0900

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

diff --git a/ChangeLog b/ChangeLog
index 048348a..c6b07d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-09-06  Jihoon Kim
+
+       * ecore_imf: Fix memory leak in scim immodule
+
 2013-09-06  Cedric Bail
 
        * Edje: Add border information to Image sets.
diff --git a/NEWS b/NEWS
index 35a7f1d..be7c068 100644
--- a/NEWS
+++ b/NEWS
@@ -378,6 +378,7 @@ Fixes:
      - Check the state of last mouse event more properly.
     * Ecore-imf:
      - Fix crash when ecore_imf_context_del is called in 
ecore_imf_context_input_panel_callback_call.
+     - Fix memory leak in scim immodule
     * Eio:
      - Don't leak fd on exec.
      - eio functions no longer crash when passed NULL and throw errors 
accordingly.
diff --git a/src/modules/ecore_imf/scim/scim_imcontext.cpp 
b/src/modules/ecore_imf/scim/scim_imcontext.cpp
index 43392bb..f5bd678 100644
--- a/src/modules/ecore_imf/scim/scim_imcontext.cpp
+++ b/src/modules/ecore_imf/scim/scim_imcontext.cpp
@@ -2721,8 +2721,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();

-- 

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk

Reply via email to