mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Add check and exception for repeated deallocation of a pool.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39706 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
de8428ab4a
commit
51f4463702
2 changed files with 22 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue