summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-09-02 20:54:51 +0000
committermichi_cc <michi_cc@openttd.org>2011-09-02 20:54:51 +0000
commitf227e90c248b37fe50c9e48a08a1bb976c782e9f (patch)
tree08d88d27ff581ebc89f0f16acb35d156ad6a84be /src/pathfinder
parent65637d89411e96dee5ee9fc2e8a7b3805c4162a2 (diff)
downloadopenttd-f227e90c248b37fe50c9e48a08a1bb976c782e9f.tar.xz
(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/npf/queue.cpp3
1 files changed, 3 insertions, 0 deletions
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;