Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -27,20 +27,23 @@ size_t fill = count * 4 / *size; size_t newsize; struct of_dictionary_bucket *newdata; uint32_t i; - if (fill > 3) { - if (*size > SIZE_MAX / 8) - @throw [OFOutOfRangeException newWithClass: isa]; + if (count > SIZE_MAX / 4) + @throw [OFOutOfRangeException newWithClass: isa]; + if (fill > 3) newsize = *size << 1; - } else if (fill < 1) + else if (fill < 1) newsize = *size >> 1; else return; + if (newsize == 0) + @throw [OFOutOfRangeException newWithClass: isa]; + newdata = [self allocMemoryForNItems: newsize withSize: BUCKET_SIZE]; memset(newdata, 0, newsize * BUCKET_SIZE); for (i = 0; i < *size; i++) {