Mercurial > hg > openttd
changeset 14421:d8710fbbbacd draft
(svn r18978) -Fix [FS#3584](r14753): possible invalid memory access when merging companies
author | smatz <smatz@openttd.org> |
---|---|
date | Mon, 01 Feb 2010 00:10:52 +0000 |
parents | 0b3ad86407fd |
children | 65de2573b474 |
files | src/vehicle.cpp |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1209,10 +1209,10 @@ 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) {