From 703262c21368a3d0a5b8f70a723b90d511b65a2c Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 29 Sep 2016 13:10:43 +0900 Subject: [PATCH] Fix invalid memory access issue g_text_input could not be initialized if text_input->input_methods is NULL in _e_text_input_cb_destroy(). It makes invalid memory access. Change-Id: I2fd821941ccec176f1b91dddf8eff1bc76e9f059 Signed-off-by: Jihoon Kim --- src/e_mod_main.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index c86d788..da09bd0 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -399,8 +399,17 @@ _e_text_input_method_context_grab_set(E_Input_Method_Context *context, Eina_Bool e_comp_ungrab_input(0, 1); - if (context->kbd.keymap) xkb_map_unref(context->kbd.keymap); - if (context->kbd.state) xkb_state_unref(context->kbd.state); + if (context->kbd.keymap) + { + xkb_map_unref(context->kbd.keymap); + context->kbd.keymap = NULL; + } + + if (context->kbd.state) + { + xkb_state_unref(context->kbd.state); + context->kbd.state = NULL; + } } } #endif @@ -1093,8 +1102,6 @@ err: static void _e_text_input_cb_deactivate(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat) { - g_text_input = NULL; - g_client = NULL; E_Text_Input *text_input = wl_resource_get_user_data(resource); E_Input_Method *input_method = NULL; @@ -1106,6 +1113,12 @@ _e_text_input_cb_deactivate(struct wl_client *client EINA_UNUSED, struct wl_reso return; } + if (text_input == g_text_input) + { + g_text_input = NULL; + g_client = NULL; + } + /* FIXME: should get input_method object from seat. */ if (g_input_method && g_input_method->resource) input_method = wl_resource_get_user_data(g_input_method->resource); @@ -1650,19 +1663,20 @@ _e_text_input_cb_destroy(struct wl_resource *resource) return; } - EINA_LIST_FREE(text_input->input_methods, input_method) + if (g_text_input == text_input) { - if (g_text_input == text_input) + if (text_input->input_panel_visibile) { - if (text_input->input_panel_visibile) - { - if (g_client) - _input_panel_hide(g_client, resource, EINA_TRUE); - } - - g_text_input = NULL; + if (g_client) + _input_panel_hide(g_client, resource, EINA_TRUE); } + g_text_input = NULL; + g_client = NULL; + } + + EINA_LIST_FREE(text_input->input_methods, input_method) + { _e_text_input_deactivate(text_input, input_method); } -- 2.34.1