jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=b29847e0da30512be7ad46777383502eaa38452d
commit b29847e0da30512be7ad46777383502eaa38452d Author: Jean-Philippe Andre <jp.an...@samsung.com> Date: Thu Aug 11 11:34:00 2016 +0900 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. --- src/lib/ecore_wl2/ecore_wl2_display.c | 4 ++-- src/lib/elementary/elm_config.c | 1 + .../ecore_evas/engines/wayland/ecore_evas_wayland_egl.c | 11 +++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index 77f6b28..c536d56 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -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); diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index a4d687a..728e85d 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -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 diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c index bb50fd8..c02619d 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c @@ -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; --