diff --git a/ChangeLog b/ChangeLog index b6a7db512..3901e1f12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ * Source/NSConnection.m: When creating a connection and getting its proxy, release the connection immediately if the proxy is nil, so that repeated calls don't use more resources. + * Source/NSNSAutoreleasePool.m: When emptying pool, add diagnostic + message and exceptions where an object we are releasing is bad in + some way. 2008-02-17 19:21-EST Gregory John Casamento diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index bd165cf83..fc16e466d 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -385,22 +385,44 @@ static IMP initImp; for (i = 0; i < released->count; i++) { - id anObject = objects[i]; - Class c = GSObjCClass(anObject); - unsigned hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f; + id anObject; + Class c; + unsigned hash; + anObject = objects[i]; objects[i] = nil; + if (anObject == nil) + { + fprintf(stderr, + "nil object encountered in autorelease pool\n"); + continue; + } + c = GSObjCClass(anObject); + if (c == 0) + { + [NSException raise: NSInternalInconsistencyException + format: @"nul class for object in autorelease pool"]; + } + hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f; if (classes[hash] != c) { - classes[hash] = c; + IMP imp; + if (GSObjCIsInstance(anObject)) { - imps[hash] = [c instanceMethodForSelector: releaseSel]; + imp = [c instanceMethodForSelector: releaseSel]; } else { - imps[hash] = [c methodForSelector: releaseSel]; + imp = [c methodForSelector: releaseSel]; } + if (imp == 0) + { + [NSException raise: NSInternalInconsistencyException + format: @"nul release for object in autorelease pool"]; + } + classes[hash] = c; + imps[hash] = imp; } (imps[hash])(anObject, releaseSel); }