From 2e0bf3b0f6debd8268711aea0d380ee07cf6a316 Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 10 Jun 2012 07:53:43 +0000 Subject: [PATCH 1/1] Eo: Added a check if object is already deleted in eo_unref. If an object is manually freed it was possible to ref/unref it so it'll try to call the destructor again. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@71890 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- lib/eo.c | 6 ++++++ tests/eo_test_general.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/eo.c b/lib/eo.c index fcfbfdf..823f344 100644 --- a/lib/eo.c +++ b/lib/eo.c @@ -1294,6 +1294,12 @@ _eo_unref(Eo *obj) { if (--(obj->refcount) == 0) { + if (obj->del) + { + ERR("Object %p already deleted.", obj); + return; + } + _eo_del_internal(obj); #ifndef NDEBUG diff --git a/tests/eo_test_general.c b/tests/eo_test_general.c index 12f79dd..30a5cb6 100644 --- a/tests/eo_test_general.c +++ b/tests/eo_test_general.c @@ -181,6 +181,15 @@ START_TEST(eo_man_free) eo_manual_free(obj); eo_unref(obj); + obj = eo_add(klass, NULL); + fail_if(!obj); + eo_manual_free_set(obj, EINA_TRUE); + eo_unref(obj); + eo_ref(obj); + eo_unref(obj); + eo_unref(obj); + eo_manual_free(obj); + eo_shutdown(); } END_TEST -- 2.7.4