From 951bed62063543b48ebf06ea174588b4adcacc83 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 20 Nov 2012 14:41:13 +0900 Subject: [PATCH] Allow the retain count to become 0. With the new retain count scheme, it must reach 0 or double frees won't be caught. --- ruamoko/lib/Object.r | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ruamoko/lib/Object.r b/ruamoko/lib/Object.r index ae7c9a26a..5e2b28592 100644 --- a/ruamoko/lib/Object.r +++ b/ruamoko/lib/Object.r @@ -292,10 +292,13 @@ BOOL (id object) object_is_meta_class = #0; - (/*oneway*/ void) release { - if ([self retainCount] == 1) // don't let retain count reach zero + int rc; + + rc = obj_decrement_retaincount (self); + if (rc < 0) + obj_error (self, 0, "retain count went negative"); + if (rc == 0) [self dealloc]; - else - obj_decrement_retaincount (self); } - (id) autorelease