# HG changeset patch # User smatz # Date 2010-07-02 09:09:40 # Node ID 09ad3f13dbc1c2c1efc44cb67a75df50c5c30ae0 # Parent 70dc7e2af5436aedc9ac3a8d395860a109148ada (svn r20041) -Fix [FS#3892](r19955): crash when spectator tried to open a vehicle list without selecting any company diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1275,8 +1275,12 @@ static WindowDesc _vehicle_list_desc( static void ShowVehicleListWindowLocal(CompanyID company, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number) { if (!Company::IsValidID(company)) { + company = _local_company; + /* This can happen when opening the vehicle list as a spectator. + * While it would be cleaner to check this somewhere else, having + * it here reduces code duplication */ + if (!Company::IsValidID(company)) return; _vehicle_list_desc.flags |= WDF_CONSTRUCTION; - company = _local_company; } else { _vehicle_list_desc.flags &= ~WDF_CONSTRUCTION; }