Add same object/key to NSMapTable
Add same object/key to NSMapTable
- Subject: Add same object/key to NSMapTable
- From: Nathan Vander Wilt <email@hidden>
- Date: Wed, 17 Jun 2009 18:33:32 -0700
The following (simplified test case) code will crash with
NSZombieEnabled:
NSMapTable* testTable = [NSMapTable mapTableWithStrongToStrongObjects];
NSString* o = [@"test_object" mutableCopy];
NSString* k = @"test_key";
[testTable setObject:o forKey:k];
[o release];
[testTable setObject:o forKey:k]; // crash
What seems to be happening is that -[NSMapTable setObject:forKey:]
does a plain release on the key's "old" object before retaining the
"new" object. This can result in the situation above, where the retain
of the "new" object is performed on a zombie created by the release of
the (identical) "old".
I could find no documentation to the effect that re-assigning an
object is not allowed, so can I assume this is indeed unintentional?
If so, I've got this test case in project form and would be happy to
file a bug.
thanks,
-natevw
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden