From 7ac9e7cd4fd80c9dd655dc85f149a590abdeed4f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 21 Aug 2012 12:15:54 +0000 Subject: [PATCH] Eo: Add an error if we get to a negative refcount. SVN revision: 75505 --- legacy/eobj/src/lib/eo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c index 2eae61ab06..12812fb3a7 100644 --- a/legacy/eobj/src/lib/eo.c +++ b/legacy/eobj/src/lib/eo.c @@ -1272,7 +1272,8 @@ _eo_free(Eo *obj) static inline void _eo_unref(Eo *obj) { - if (--(obj->refcount) == 0) + --(obj->refcount); + if (obj->refcount == 0) { if (obj->del) { @@ -1298,6 +1299,11 @@ _eo_unref(Eo *obj) else _eo_ref(obj); /* If we manual free, we keep a phantom ref. */ } + else if (obj->refcount < 0) + { + ERR("Obj:%p. Refcount (%d) < 0. Too many unrefs.", obj, obj->refcount); + return; + } } EAPI void