Eo: Added a check if object is already deleted in eo_unref.
authortasn <tasn>
Sun, 10 Jun 2012 07:53:43 +0000 (07:53 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 10 Jun 2012 07:53:43 +0000 (07:53 +0000)
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
tests/eo_test_general.c

index fcfbfdf..823f344 100644 (file)
--- 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
index 12f79dd..30a5cb6 100644 (file)
@@ -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