@@ -19,12 +19,10 @@ #include #include #include #include -#include - #import "runtime.h" #import "runtime-private.h" uint32_t objc_hash_string(const char *str) @@ -72,17 +70,20 @@ { uint32_t i, hash, last; struct objc_hashtable_bucket *bucket; hash = objc_hash_string(key); - assert(h->count + 1 <= UINT32_MAX / 4); + + if (h->count + 1 > UINT32_MAX / 4) + OBJC_ERROR("Integer overflow!"); if ((h->count + 1) * 4 / (h->last_idx + 1) >= 3) { struct objc_hashtable_bucket **ndata; uint32_t nsize = (h->last_idx + 1) * 2; - assert(nsize > 0); + if (nsize == 0) + OBJC_ERROR("Integer overflow!"); ndata = malloc(nsize * sizeof(struct objc_hashtable_bucket*)); if (ndata == NULL) OBJC_ERROR("Not enough memory to insert into hash " "table!");