summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-11-23 18:07:11 +0000
committerrubidium <rubidium@openttd.org>2013-11-23 18:07:11 +0000
commitd18852170b99e6cd20a23ef7305cecd7b741a808 (patch)
tree03ab98cdda0ef929cc7b54e34314af848642a6b9 /src
parentc29f18f357fc4a5ce1c7315e744cbe601dac38c4 (diff)
downloadopenttd-d18852170b99e6cd20a23ef7305cecd7b741a808.tar.xz
(svn r26066) -Fix: possible NULL dereference when resolving industry scope
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_industries.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 6716d2c03..e0953434e 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -447,13 +447,15 @@ TownScopeResolver *IndustriesResolverObject::GetTown()
{
if (this->town_scope == NULL) {
Town *t = NULL;
+ bool readonly = true;
if (this->industries_scope.industry != NULL) {
t = this->industries_scope.industry->town;
+ readonly = this->industries_scope.industry->index == INVALID_INDUSTRY;
} else if (this->industries_scope.tile != INVALID_TILE) {
t = ClosestTownFromTile(this->industries_scope.tile, UINT_MAX);
}
if (t == NULL) return NULL;
- this->town_scope = new TownScopeResolver(this, t, this->industries_scope.industry->index == INVALID_INDUSTRY);
+ this->town_scope = new TownScopeResolver(this, t, readonly);
}
return this->town_scope;
}