static void
update_state(WaylandIMContext *imcontext)
{
- char *surrounding;
+ char *surrounding = NULL;
int cursor_pos;
Ecore_Evas *ee;
int canvas_x = 0, canvas_y = 0;
if (imcontext->text_input)
wl_text_input_set_surrounding_text(imcontext->text_input, surrounding,
cursor_pos, cursor_pos);
- free(surrounding);
+
+ if (surrounding)
+ free(surrounding);
}
if (imcontext->canvas)
imcontext->pending_commit.anchor = 0;
imcontext->pending_preedit.cursor = 0;
- EINA_LIST_FREE(imcontext->pending_preedit.attrs, attr) free(attr);
- imcontext->pending_preedit.attrs = NULL;
+
+ if (imcontext->pending_preedit.attrs)
+ {
+ EINA_LIST_FREE(imcontext->pending_preedit.attrs, attr) free(attr);
+ imcontext->pending_preedit.attrs = NULL;
+ }
return EINA_FALSE;
}
static void
clear_preedit(WaylandIMContext *imcontext)
{
- Ecore_IMF_Preedit_Attr *attr;
+ Ecore_IMF_Preedit_Attr *attr = NULL;
imcontext->preedit_cursor = 0;
- free(imcontext->preedit_text);
- imcontext->preedit_text = NULL;
+ if (imcontext->preedit_text)
+ {
+ free(imcontext->preedit_text);
+ imcontext->preedit_text = NULL;
+ }
- free(imcontext->preedit_commit);
- imcontext->preedit_commit = NULL;
+ if (imcontext->preedit_commit)
+ {
+ free(imcontext->preedit_commit);
+ imcontext->preedit_commit = NULL;
+ }
- EINA_LIST_FREE(imcontext->preedit_attrs, attr)
- free(attr);
+ if (imcontext->preedit_attrs)
+ {
+ EINA_LIST_FREE(imcontext->preedit_attrs, attr)
+ free(attr);
+ }
imcontext->preedit_attrs = NULL;
}
{
WaylandIMContext *imcontext = (WaylandIMContext *)data;
Eina_Bool old_preedit = EINA_FALSE;
- char *surrounding;
+ char *surrounding = NULL;
int cursor_pos, cursor;
Ecore_IMF_Event_Delete_Surrounding ev;
"delete on commit (text: `%s', offset `%d', length: `%d')",
surrounding, ev.offset, ev.n_chars);
- free(surrounding);
+ if (surrounding)
+ free(surrounding);
ecore_imf_context_delete_surrounding_event_add(imcontext->ctx, ev.offset, ev.n_chars);
ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev);
ECORE_IMF_CALLBACK_PREEDIT_CHANGED,
NULL);
- if (strlen(imcontext->preedit_text) == 0)
+ if (imcontext->preedit_text && strlen(imcontext->preedit_text) == 0)
{
ecore_imf_context_preedit_end_event_add(imcontext->ctx);
ecore_imf_context_event_callback_call(imcontext->ctx,