@@ -85,11 +85,11 @@ return self; } - initWithDictionary: (OFDictionary*)dict { - size_t i; + uint32_t i; self = [super init]; if (dict == nil) { Class c = isa; @@ -204,15 +204,18 @@ @try { keys_carray = [keys cArray]; objs_carray = [objs cArray]; count = [keys count]; - if (count > SIZE_MAX / 8) + if (count > UINT32_MAX) @throw [OFOutOfRangeException newWithClass: isa]; for (size = 1; size < count; size <<= 1); + if (size == 0) + @throw [OFOutOfRangeException newWithClass: isa]; + data = [self allocMemoryForNItems: size withSize: BUCKET_SIZE]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. Compiler bug? @@ -337,17 +340,23 @@ count = 1; for (va_copy(args2, args); va_arg(args2, OFObject*) != nil; count++); count >>= 1; - if (count > SIZE_MAX / 8) { + if (count > UINT32_MAX) { Class c = isa; [self dealloc]; @throw [OFOutOfRangeException newWithClass: c]; } for (size = 1; size < count; size <<= 1); + + if (size == 0) { + Class c = isa; + [self dealloc]; + @throw [OFOutOfRangeException newWithClass: c]; + } @try { data = [self allocMemoryForNItems: size withSize: BUCKET_SIZE]; } @catch (OFException *e) { @@ -393,11 +402,11 @@ data[j].key = key; data[j].object = obj; data[j].hash = hash; for (i = 1; i < count; i++) { - size_t last; + uint32_t last; key = va_arg(args, OFObject *); obj = va_arg(args, OFObject*); if (key == nil || obj == nil) { @@ -539,11 +548,11 @@ return [[OFMutableDictionary alloc] initWithDictionary: self]; } - (BOOL)isEqual: (OFDictionary*)dict { - size_t i; + uint32_t i; if ([dict count] != count) return NO; for (i = 0; i < size; i++) @@ -556,11 +565,11 @@ - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ { - size_t i; + int i; for (i = 0; i < count_; i++) { for (; state->state < size && (data[state->state].key == nil || data[state->state].key == DELETED); state->state++); @@ -593,11 +602,11 @@ mutationsPointer: NULL] autorelease]; } - (void)dealloc { - size_t i; + uint32_t i; for (i = 0; i < size; i++) { if (data[i].key != nil && data[i].key != DELETED) { [data[i].key release]; [data[i].object release]; @@ -607,11 +616,11 @@ [super dealloc]; } - (uint32_t)hash { - size_t i; + uint32_t i; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < size; i++) { @@ -637,11 +646,11 @@ @end /// \cond internal @implementation OFDictionaryEnumerator - initWithData: (struct of_dictionary_bucket*)data_ - size: (size_t)size_ + size: (uint32_t)size_ mutationsPointer: (unsigned long*)mutations_ptr_ { self = [super init]; data = data_;