summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-08 17:07:35 +0000
committerrubidium <rubidium@openttd.org>2010-04-08 17:07:35 +0000
commit54067acb0fad35c52ea0b5a750168a62b236f8d3 (patch)
treef9eef7290a8058d8cb6fa917c2f226a35e0ea9c5
parentfb364e4426d23a84aa3f36a594ece73ddc0fed70 (diff)
downloadopenttd-54067acb0fad35c52ea0b5a750168a62b236f8d3.tar.xz
(svn r19586) -Fix: some false positives in cache validity checks because cache = v->cache doesn't necessarily write all sizeof(Cache) bytes
-rw-r--r--src/openttd.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 4c25fd1c6..8f6edee8b 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1111,7 +1111,9 @@ static void CheckCaches()
switch (v->type) {
case VEH_ROAD: {
RoadVehicle *rv = RoadVehicle::From(v);
- RoadVehicleCache cache = rv->rcache;
+ RoadVehicleCache cache;
+ memset(&cache, 0, sizeof(cache));
+ cache = rv->rcache;
RoadVehUpdateCache(rv);
if (memcmp(&cache, &rv->rcache, sizeof(RoadVehicleCache)) != 0) {
@@ -1124,7 +1126,7 @@ static void CheckCaches()
Train *t = Train::From(v);
for (Vehicle *u = t; u != NULL; u = u->Next()) length++;
- TrainCache *wagons = MallocT<TrainCache>(length);
+ TrainCache *wagons = CallocT<TrainCache>(length);
length = 0;
for (Train *u = t; u != NULL; u = u->Next()) wagons[length++] = u->tcache;
@@ -1143,7 +1145,9 @@ static void CheckCaches()
case VEH_AIRCRAFT: {
Aircraft *a = Aircraft::From(v);
- AircraftCache cache = a->acache;
+ AircraftCache cache;
+ memset(&cache, 0, sizeof(cache));
+ cache = a->acache;
UpdateAircraftCache(a);
if (memcmp(&cache, &a->acache, sizeof(AircraftCache)) != 0) {