From f227e90c248b37fe50c9e48a08a1bb976c782e9f Mon Sep 17 00:00:00 2001 From: michi_cc Date: Fri, 2 Sep 2011 20:54:51 +0000 Subject: (svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid) --- src/pathfinder/npf/queue.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pathfinder') diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp index b235c3b0e..b12c59d6c 100644 --- a/src/pathfinder/npf/queue.cpp +++ b/src/pathfinder/npf/queue.cpp @@ -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; -- cgit v1.2.3-54-g00ecf