From 4ba44bd86524973013229a9a5d8f4c92b74ef56a Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sat, 26 Mar 2022 23:03:20 +0000 Subject: [PATCH] elm - be more robust in the face of null cnp obj and bad app code someone decided passing a null obj to elm_cnp_selection_set from an app is a good idea. it's not... but let's not crash 9nside efl if someone does and instead survive and complain @fix --- src/lib/elementary/efl_ui_win.c | 1 + src/lib/elementary/elm_cnp.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index d261d39953..e320795d5f 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -9226,6 +9226,7 @@ _ui_buffer_get(Ecore_Evas_Selection_Buffer buffer) void _register_selection_changed(Efl_Ui_Selection *selection) { + if (!selection) return; ELM_WIN_DATA_GET(efl_provider_find(selection, EFL_UI_WIN_CLASS), pd); eina_array_push(pd->planned_changes, selection); diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c index ded6e10503..2c6578ef82 100644 --- a/src/lib/elementary/elm_cnp.c +++ b/src/lib/elementary/elm_cnp.c @@ -127,6 +127,18 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Eina_Array *tmp; unsigned char *mem_buf = NULL; + if (!obj) + { + ERR("elm_cnp_selection_set() passed NULL object"); + return EINA_FALSE; + } + ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); + if (!ee) + { + ERR("elm_cnp_selection_set() can't fine ecore_evas for obj %p", obj); + return EINA_FALSE; + } + if (format == ELM_SEL_FORMAT_TEXT && ((char*)buf)[buflen - 1] != '\0') { mem_buf = eina_memdup((unsigned char *)buf, buflen, EINA_TRUE); @@ -139,8 +151,6 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, data.len = buflen; } - ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); - if (format == ELM_SEL_FORMAT_IMAGE) { tmp = _elm_sel_from_content_to_mime_type(buf, buflen);