From c02bab4149b2f3984d0f7a0637003d2bcd62fabd Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 20 May 2015 16:48:20 +0100 Subject: [PATCH] Eo: Better handle object cleanup on failure. While unrefing twice works, it's cleaner to unref the ref we have and delete normally. It will handle parnet detachments in a nicer way, and is just more correct. --- src/lib/eo/eo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index dffdcdb639..766b7d3cb8 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -926,9 +926,8 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo { ERR("Object of class '%s' - Error while constructing object", klass->desc->name); - /* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */ - _eo_unref(obj); _eo_unref(obj); + eo_del((Eo *) obj->header.id); return NULL; } @@ -981,9 +980,8 @@ _eo_add_internal_end(Eo *eo_id) return (Eo *)eo_id; cleanup: - /* Unref twice, once for the ref in _eo_add_internal_start, and once for the basic object ref. */ - _eo_unref(fptr->o.obj); _eo_unref(fptr->o.obj); + eo_del((Eo *) fptr->o.obj->header.id); return NULL; }