From 85a9bd54303dc0a221b0825b396cd5d62386ca15 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 5 Jul 2016 19:12:23 +0900 Subject: [PATCH] eo: Fix crash during eo_shutdown I was getting a crash in eo_shutdown, inside _efl_event_pointer_class_destructor as I was calling eo_del from there. But the parent class was already destroyed. Assuming class IDs can only go up, and child classes are only instanciated after all their parents, it is safer to call the class destructors in reverse order. Obviously, still pretty sure eo_del() in a class_destructor is not a good idea... --- src/lib/eo/eo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index eec43ff..f147f0d 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1727,7 +1727,7 @@ EAPI Eina_Bool eo_shutdown(void) { size_t i; - _Eo_Class **cls_itr = _eo_classes; + _Eo_Class **cls_itr = _eo_classes + _eo_classes_last_id - 1; if (--_eo_init_count > 0) return EINA_TRUE; @@ -1738,7 +1738,7 @@ eo_shutdown(void) _eo_add_fallback_shutdown(); - for (i = 0 ; i < _eo_classes_last_id ; i++, cls_itr++) + for (i = 0 ; i < _eo_classes_last_id ; i++, cls_itr--) { if (*cls_itr) eo_class_free(*cls_itr); -- 2.7.4