diff --git a/ChangeLog b/ChangeLog index d7936c90f..4d9392817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-04-28 Richard Frith-Macdonald + + * Source/NSAutoreleasePool.m: + Check for a pool being deallocated when it has already been + deallocated (and raise an exception). + 2016-04-23 Marcus Mueller * Source/GSAvahiNetService.m: Avahi-based NSNetServices did crash @@ -6,12 +12,12 @@ 2016-04-08 Richard Frith-Macdonald - * Source/NSUserDefaults.m + * Source/NSUserDefaults.m: Remove redundant code. Log domain names when debug is enabled. 2016-04-08 Riccardo Mottola - * Source/NSUserDefaults.m + * Source/NSUserDefaults.m: Skip nil domains explicitely and do not use nil values to look them up. 2016-04-04 Niels Grewe diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index b6cab486e..6f04c20cc 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -295,9 +295,14 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) + (id) allocWithZone: (NSZone*)zone { struct autorelease_thread_vars *tv = ARP_THREAD_VARS; - if (tv->pool_cache_count) - return pop_pool_from_cache (tv); + if (tv->pool_cache_count) + { + NSAutoreleasePool *p = pop_pool_from_cache (tv); + + NSAssert(++(p->_released_count) == 0, @"corrupted pool in cache"); + return p; + } return NSAllocateObject (self, 0, zone); } @@ -720,6 +725,13 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) _parent = nil; } + if (_released_count-- != 0) + { + _released_count++; + [NSException raise: NSInternalInconsistencyException + format: @"NSAutoreleasePool -dealloc of deallocated pool"]; + } + /* Don't deallocate ourself, just save us for later use. */ push_pool_to_cache (tv, self); GSNOSUPERDEALLOC;