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
This commit is contained in:
Carsten Haitzler 2022-03-26 23:03:20 +00:00
parent da0a6f9ed0
commit 4ba44bd865
2 changed files with 13 additions and 2 deletions

View File

@ -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);

View File

@ -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);