summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@webkeks.org>2011-04-28 20:03:34 +0200
committerJonathan Schleifer <js@webkeks.org>2011-04-28 20:03:34 +0200
commit645b97adbc03802452fec784882d001a169cdb4b (patch)
tree769a0219b806d64f490d9c88b0a604815c1fd193
parent08147856da0abe991773b5130315400c8ef84990 (diff)
Don't allow nil in -[initWithObjectForKey:] and optimize -[description].
-rw-r--r--src/OFDictionary.m14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/OFDictionary.m b/src/OFDictionary.m
index 066c05d9..75418740 100644
--- a/src/OFDictionary.m
+++ b/src/OFDictionary.m
@@ -149,6 +149,10 @@ struct of_dictionary_bucket of_dictionary_deleted_bucket = {};
uint32_t i;
BUCKET *b;
+ if (key == nil || object == nil)
+ @throw [OFInvalidArgumentException newWithClass: isa
+ selector: _cmd];
+
data = [self allocMemoryForNItems: 2
withSize: sizeof(BUCKET*)];
@@ -708,17 +712,19 @@ struct of_dictionary_bucket of_dictionary_deleted_bucket = {};
{
OFMutableString *ret = [OFMutableString stringWithString: @"{\n"];
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
- OFEnumerator *enumerator = [self keyEnumerator];
- id key;
+ OFEnumerator *keyEnumerator = [self keyEnumerator];
+ OFEnumerator *objectEnumerator = [self objectEnumerator];
+ id key, object;
size_t i;
i = 0;
pool2 = [[OFAutoreleasePool alloc] init];
- while ((key = [enumerator nextObject]) != nil) {
+ while ((key = [keyEnumerator nextObject]) != nil &&
+ (object = [objectEnumerator nextObject]) != nil) {
[ret appendString: [key description]];
[ret appendString: @" = "];
- [ret appendString: [[self objectForKey: key] description]];
+ [ret appendString: [object description]];
if (++i < count)
[ret appendString: @";\n"];