Files
@ r27008:1819ba4d5c84
Branch filter:
Location: cpp/openttd-patchpack/source/src/cheat_func.h
r27008:1819ba4d5c84
809 B
text/x-c
Fix: crashes to desktop from game scripts when companies disappear
When a game script is in company mode, it pretends to be another company. When
that company disappear (bankruptcy/merger), the game script still uses that
company and it keeps calling functions as if it is that company.
For example, ScriptEngine::IsBuildable internally dereferences Company without
checks, causing a null dereference for any ScriptEngine function when called
from a company scope of a company that has disappeared.
Guard against this by extending the ScriptCompanyScope::IsValid check to also
check for the company still being active.
When a game script is in company mode, it pretends to be another company. When
that company disappear (bankruptcy/merger), the game script still uses that
company and it keeps calling functions as if it is that company.
For example, ScriptEngine::IsBuildable internally dereferences Company without
checks, causing a null dereference for any ScriptEngine function when called
from a company scope of a company that has disappeared.
Guard against this by extending the ScriptCompanyScope::IsValid check to also
check for the company still being active.