From 769fa4b592fdc5849312cef6603dbdac20041592 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 9 Aug 2019 09:16:45 -0400 Subject: [PATCH] elm_test: fix crashing in efl.ui.popup when closing windows avoid double free on pointer in callback Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D9540 --- src/bin/elementary/test_ui_popup.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin/elementary/test_ui_popup.c b/src/bin/elementary/test_ui_popup.c index 89a9f0ef1b..cf809106c1 100644 --- a/src/bin/elementary/test_ui_popup.c +++ b/src/bin/elementary/test_ui_popup.c @@ -214,8 +214,12 @@ static void _win_del(void *data, const Efl_Event *ev EINA_UNUSED) { efl_ui_popup_data *p_data = data; - efl_unref(p_data->panel_win); - free(p_data); + Eo *win = p_data->panel_win; + p_data->panel_win = NULL; + /* only free pointer if the other window has already been freed */ + if (!p_data->win) + free(p_data); + efl_unref(win); printf("window is deleted\n"); } @@ -223,8 +227,12 @@ static void _panel_win_del(void *data, const Efl_Event *ev EINA_UNUSED) { efl_ui_popup_data *p_data = data; - efl_unref(p_data->win); - free(p_data); + Eo *win = p_data->win; + p_data->win = NULL; + /* only free pointer if the other window has already been freed */ + if (!p_data->win) + free(p_data); + efl_unref(win); printf("window is deleted\n"); }