(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)

This commit is contained in:
michi_cc
2011-09-02 20:54:51 +00:00
parent 65637d8941
commit f227e90c24
6 changed files with 22 additions and 1 deletions

View File

@@ -234,6 +234,9 @@ void Hash::Init(Hash_HashProc *hash, uint num_buckets)
/* Allocate space for the Hash, the buckets and the bucket flags */
uint i;
/* Ensure the size won't overflow. */
assert(num_buckets < SIZE_MAX / (sizeof(*this->buckets) + sizeof(*this->buckets_in_use)));
this->hash = hash;
this->size = 0;
this->num_buckets = num_buckets;