diff --git a/ChangeLog b/ChangeLog index 048348a73b..c6b07d4874 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 35a7f1d6e6..be7c068356 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 43392bb5b6..f5bd678ca3 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();