summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-02-27 15:01:34 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-02-27 15:05:35 -0800
commit2c6808e4eed28d5b93d2f10b558b168aa365364e (patch)
treeaba89541311a4955ab7967a9e7423f48f185b3e1
parent30c5225bec62dff8f225d8e87fa64d0a78848ba1 (diff)
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.
-rw-r--r--src/lib/ecore/ecore.c7
-rw-r--r--src/lib/ecore/ecore_events.c1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 6c0a31e185..e531c1ca81 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -354,6 +354,13 @@ ecore_shutdown(void)
354 ERR("Init count not greater than 0 in shutdown."); 354 ERR("Init count not greater than 0 in shutdown.");
355 return 0; 355 return 0;
356 } 356 }
357
358 // We need to flush all pending event as this is
359 // the only way to properly avoid use after free
360 // during shutdown of component that may have
361 // emitted and still pending event.
362 _ecore_event_call();
363
357 if (_ecore_init_count-- != _ecore_init_count_threshold) 364 if (_ecore_init_count-- != _ecore_init_count_threshold)
358 goto end; 365 goto end;
359 366
diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c
index aa4bde56ed..db24688d92 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)
605{ 605{
606 return calloc(1, sizeof(Ecore_Event_Signal_Realtime)); 606 return calloc(1, sizeof(Ecore_Event_Signal_Realtime));
607} 607}
608