From e2944780fad775de31f99fc8dd6d93528bbdc7ae Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Wed, 19 Aug 2020 11:50:31 +0000 Subject: [PATCH] ecore_wl2_display: move wl_display_dispatch_pending before condition check. Sometimes display ref count is not zero after wl_display_dispatch_pending. For example, wl_data_source_listener's callback is called by wl_display_dispatch_pending. Display ref count is not zero but display is cleaned up, it makes double free corruption. Reviewed-by: Christopher Michael Differential Revision: https://phab.enlightenment.org/D12109 --- src/lib/ecore_wl2/ecore_wl2_display.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index a91285e466..7344cf8b74 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -965,17 +965,16 @@ EAPI void ecore_wl2_display_disconnect(Ecore_Wl2_Display *display) { EINA_SAFETY_ON_NULL_RETURN(display); + int ret; + + do + { + ret = wl_display_dispatch_pending(display->wl.display); + } while (ret > 0); --display->refs; if (display->refs == 0) { - int ret; - - do - { - ret = wl_display_dispatch_pending(display->wl.display); - } while (ret > 0); - _ecore_wl2_display_cleanup(display); wl_display_disconnect(display->wl.display);