(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user