From: Cedric BAIL Date: Mon, 27 Feb 2017 23:01:34 +0000 (-0800) Subject: ecore: forcefully flush pending event when ecore_shutdown is called. X-Git-Tag: upstream/1.20.0~1877 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c6808e4eed28d5b93d2f10b558b168aa365364e;p=platform%2Fupstream%2Fefl.git ecore: forcefully flush pending event when ecore_shutdown is called. If a component emit Ecore_Event and they aren't processed before the call it call ecore_shutdown, there is no way to prevent this event from being triggered after the component at shutdown itself. Which may well lead to a use after free case. As we don't know which event are pending and we also are not shuting down ecore completely as they are still other component using it, we can only flush all pending event right away. --- diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index 6c0a31e..e531c1c 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -354,6 +354,13 @@ ecore_shutdown(void) ERR("Init count not greater than 0 in shutdown."); return 0; } + + // We need to flush all pending event as this is + // the only way to properly avoid use after free + // during shutdown of component that may have + // emitted and still pending event. + _ecore_event_call(); + if (_ecore_init_count-- != _ecore_init_count_threshold) goto end; diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c index aa4bde5..db24688 100644 --- a/src/lib/ecore/ecore_events.c +++ b/src/lib/ecore/ecore_events.c @@ -605,4 +605,3 @@ _ecore_event_signal_realtime_new(void) { return calloc(1, sizeof(Ecore_Event_Signal_Realtime)); } -