Changeset - r14411:f8ebcffe264b
[Not reviewed]
master
0 1 0
smatz - 15 years ago 2010-02-01 00:10:52
smatz@openttd.org
(svn r18978) -Fix [FS#3584](r14753): possible invalid memory access when merging companies
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -1209,10 +1209,10 @@ FreeUnitIDGenerator::FreeUnitIDGenerator
 

	
 
	if (this->maxid == 0) return;
 

	
 
	this->maxid++; // so there is space for last item (with v->unitnumber == maxid)
 
	this->maxid++; // this one will always be free (well, it will fail when there are 65535 units, so this overflows)
 

	
 
	this->cache = CallocT<bool>(this->maxid);
 
	/* Reserving 'maxid + 2' because we need:
 
	 * - space for the last item (with v->unitnumber == maxid)
 
	 * - one free slot working as loop terminator in FreeUnitIDGenerator::NextID() */
 
	this->cache = CallocT<bool>(this->maxid + 2);
 

	
 
	/* Fill the cache */
 
	FOR_ALL_VEHICLES(v) {
0 comments (0 inline, 0 general)