Fix issue detected by static analysis tool 19/291219/2
authorInHong Han <inhong1.han@samsung.com>
Wed, 12 Apr 2023 05:09:30 +0000 (14:09 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 12 Apr 2023 07:01:28 +0000 (16:01 +0900)
Dereferencing iterator it though it is already past the end of its container.

Change-Id: I9e571551e73afb943af4f284882027fcced2b895

ism/demos/isf_manual_test_efl.cpp

index e39ab76..e6514bf 100644 (file)
@@ -69,8 +69,9 @@ static void _rotate_cb (void *data, Evas_Object *obj, void *event_info)
 static void _input_panel_state_cb (void *data, Ecore_IMF_Context *ctx, int value)
 {
     map<Ecore_IMF_Context*, string>::iterator it = m_test_name.find (ctx);
-    string test = it->second;
+    if (it == m_test_name.end()) return;
 
+    string test = it->second;
     if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
         if (test == "MimeTypeSet") {
             const char *mime_type = "text/plain";
@@ -108,8 +109,9 @@ static void _focus_in_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event E
 {
     Ecore_IMF_Context *ctx = (Ecore_IMF_Context*) data;
     map<Ecore_IMF_Context*, string>::iterator it = m_test_name.find (ctx);
-    string text = it->second;
+    if (it == m_test_name.end()) return;
 
+    string text = it->second;
     if (text == "IMESizeSet") {
         char buf[256] = "ChangeIMESize";
         ecore_imf_context_input_panel_imdata_set (ctx, buf, sizeof (buf));
@@ -120,8 +122,9 @@ static void _focus_out_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event
 {
     Ecore_IMF_Context *ctx = (Ecore_IMF_Context*) data;
     map<Ecore_IMF_Context*, string>::iterator it = m_test_name.find (ctx);
-    string test = it->second;
+    if (it == m_test_name.end()) return;
 
+    string test = it->second;
     if (test == "LanguageSet") {
         ecore_imf_context_input_panel_language_set (ctx, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC);
     } else if (test == "LayoutSet") {