fix the problem that could use freed pointer as a key of hash table.
Change-Id: I967ee40e5dad5d29c7e607b25866d2055ef73202
ec->comp_data->surface = NULL;
ec->comp_data->wl_surface = NULL;
- e_pixmap_del(ec->pixmap);
+ e_pixmap_win_id_del(ec->pixmap);
_e_comp_wl_surface_render_stop(ec);
e_object_del(E_OBJECT(ec));
if ((ep = e_pixmap_find(E_PIXMAP_TYPE_WL, (uintptr_t)res)))
{
ERR("There is e_pixmap already, Delete old e_pixmap %p", ep);
- e_pixmap_del(ep);
+ e_pixmap_win_id_del(ep);
ep = NULL;
}
}
oldep = e_client_pixmap_change(ec, ep);
if (oldep)
{
- e_pixmap_del(oldep);
+ e_pixmap_win_id_del(oldep);
e_pixmap_free(oldep);
}
#include <uuid.h>
static Eina_Hash *pixmaps[E_PIXMAP_TYPE_MAX] = {NULL};
-static Eina_Hash *deleted[E_PIXMAP_TYPE_MAX] = {NULL};
static Eina_Hash *res_ids = NULL;
static uint32_t res_id = 0;
static Eina_Hash *aliases[E_PIXMAP_TYPE_MAX] = {NULL};
_e_pixmap_hook_call(E_PIXMAP_HOOK_DEL, cp);
e_pixmap_image_clear(cp, EINA_FALSE);
- eina_hash_del_by_key(pixmaps[cp->type], &cp->win);
eina_hash_del_by_key(res_ids, &cp->res_id);
- if (e_pixmap_is_del(cp))
- eina_hash_del_by_key(deleted[cp->type], &cp->win);
- else
- _e_pixmap_free(cp);
+ if (cp->win)
+ eina_hash_del_by_key(pixmaps[cp->type], &cp->win);
+
+ _e_pixmap_free(cp);
return 0;
}
E_API void
-e_pixmap_del(E_Pixmap *cp)
+e_pixmap_win_id_del(E_Pixmap *cp)
{
if (!cp) return;
if (cp->type == E_PIXMAP_TYPE_X) return;
+ if (!cp->win) return;
- if (eina_hash_find(pixmaps[cp->type], &cp->win))
- {
- eina_hash_del_by_key(pixmaps[cp->type], &cp->win);
- eina_hash_add(deleted[cp->type], &cp->win, cp);
- }
-}
-
-E_API Eina_Bool
-e_pixmap_is_del(E_Pixmap *cp)
-{
- if (!cp) return 0;
- if (cp->type == E_PIXMAP_TYPE_X) return 0;
-
- return !!eina_hash_find(deleted[cp->type], &cp->win);
+ eina_hash_del_by_key(pixmaps[cp->type], &cp->win);
+ cp->win = 0;
}
E_API E_Pixmap *
}
}
else
- {
- pixmaps[type] = eina_hash_pointer_new(NULL);
- deleted[type] = eina_hash_pointer_new((Eina_Free_Cb)_e_pixmap_free);
- }
+ pixmaps[type] = eina_hash_pointer_new(NULL);
cp = _e_pixmap_new(type);
if (!cp)
};
E_API int e_pixmap_free(E_Pixmap *cp);
-E_API void e_pixmap_del(E_Pixmap *cp);
+E_API void e_pixmap_win_id_del(E_Pixmap *cp);
E_API Eina_Bool e_pixmap_is_del(E_Pixmap *cp);
E_API E_Pixmap *e_pixmap_ref(E_Pixmap *cp);
E_API E_Pixmap *e_pixmap_new(E_Pixmap_Type type, ...);
if (ec && ec->internal)
{
- e_pixmap_del(tzsh_srv->tzsh->cp);
+ e_pixmap_win_id_del(tzsh_srv->tzsh->cp);
e_object_del(E_OBJECT(ec));
}
ec->ignored = EINA_TRUE;
}
- e_pixmap_del(tzlaunch_img->ep);
+ e_pixmap_win_id_del(tzlaunch_img->ep);
e_object_del(E_OBJECT(ec));
}
else if (!e_pixmap_resource_get(ec->pixmap))
old_ec, new_ec, tzlaunch_img->obj);
/* delete ec was created for launchscreen */
- e_pixmap_del(tzlaunch_img->ep);
+ e_pixmap_win_id_del(tzlaunch_img->ep);
e_object_del(E_OBJECT(old_ec));
tzlaunch_img->ep = NULL;
if (old_ec->visible)
{
ERR("Could not initialize launchscreen client");
if (tzlaunch_img->ep)
- e_pixmap_del(tzlaunch_img->ep);
+ e_pixmap_win_id_del(tzlaunch_img->ep);
if (tzlaunch_img->ec)
e_object_del(E_OBJECT(tzlaunch_img->ec));
E_FREE(tzlaunch_img);
if ((cp = e_pixmap_find(type, wl_win_id)))
{
ERR("There is e_pixmap already, Delete old e_pixmap %p", cp);
- e_pixmap_del(cp);
+ e_pixmap_win_id_del(cp);
cp = NULL;
}
/* first creation of pixmap for internal window */