forked from enlightenment/efl
wayland_egl: Fix double free in case of failure
When trying to create a window, the WL EGL engine creates an ecore_evas and connects to the wayland display. But if EGL is not supported (in weston with nvidia for instance), the egl initialization fails and the window must be detroyed in order to fallback to wayland_shm. This led to a double disconnect from the wayland display as both the ecore_evas del and the error handling code were trying to disconnect. Also, use ref == 0 in two places rather than ref <= 0, as it can prevent double frees in bad situations (ref < 0). And reset a global variable to NULL on shutdown.
This commit is contained in:
parent
eba63b7441
commit
b29847e0da
|
@ -710,7 +710,7 @@ ecore_wl2_display_disconnect(Ecore_Wl2_Display *display)
|
|||
EINA_SAFETY_ON_NULL_RETURN(display);
|
||||
|
||||
_ecore_wl2_display_cleanup(display);
|
||||
if (display->refs <= 0)
|
||||
if (display->refs == 0)
|
||||
{
|
||||
wl_display_disconnect(display->wl.display);
|
||||
|
||||
|
@ -728,7 +728,7 @@ ecore_wl2_display_destroy(Ecore_Wl2_Display *display)
|
|||
EINA_SAFETY_ON_NULL_RETURN(display);
|
||||
|
||||
_ecore_wl2_display_cleanup(display);
|
||||
if (display->refs <= 0)
|
||||
if (display->refs == 0)
|
||||
{
|
||||
wl_display_destroy(display->wl.display);
|
||||
|
||||
|
|
|
@ -3816,6 +3816,7 @@ _elm_config_sub_shutdown(void)
|
|||
if (_elm_wl_display)
|
||||
{
|
||||
ecore_wl2_display_disconnect(_elm_wl_display);
|
||||
_elm_wl_display = NULL;
|
||||
ecore_wl2_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -282,7 +282,7 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
|
|||
Evas_Engine_Info_Wayland_Egl *einfo;
|
||||
Ecore_Evas_Interface_Wayland *iface;
|
||||
Ecore_Evas_Engine_Wl_Data *wdata;
|
||||
Ecore_Evas *ee;
|
||||
Ecore_Evas *ee = NULL;
|
||||
int method = 0;
|
||||
int fx = 0, fy = 0, fw = 0, fh = 0;
|
||||
|
||||
|
@ -310,14 +310,14 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
|
|||
if (!(ee = calloc(1, sizeof(Ecore_Evas))))
|
||||
{
|
||||
ERR("Failed to allocate Ecore_Evas");
|
||||
goto ee_err;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data))))
|
||||
{
|
||||
ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data");
|
||||
free(ee);
|
||||
goto ee_err;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
|
||||
|
@ -460,9 +460,8 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
|
|||
return ee;
|
||||
|
||||
err:
|
||||
ecore_evas_free(ee);
|
||||
ee_err:
|
||||
ecore_wl2_display_disconnect(ewd);
|
||||
if (ee) ecore_evas_free(ee);
|
||||
else ecore_wl2_display_disconnect(ewd);
|
||||
conn_err:
|
||||
ecore_wl2_shutdown();
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue