Changeset - r28537:045dd8e45363
[Not reviewed]
master
0 2 0
Patric Stout - 11 months ago 2024-01-21 14:25:00
truebrain@openttd.org
Codechange: prevent out-of-bound read (even if the result is never used) (#11853)
2 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_config.cpp
Show inline comments
 
@@ -18,6 +18,8 @@
 

	
 
/* static */ AIConfig *AIConfig::GetConfig(CompanyID company, ScriptSettingSource source)
 
{
 
	assert(company < MAX_COMPANIES);
 

	
 
	AIConfig **config;
 
	if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) {
 
		config = &_settings_newgame.ai_config[company];
src/ai/ai_gui.cpp
Show inline comments
 
@@ -289,7 +289,7 @@ struct AIConfigWindow : public Window {
 

	
 
		if (!gui_scope) return;
 

	
 
		AIConfig *config = AIConfig::GetConfig(this->selected_slot);
 
		AIConfig *config = this->selected_slot == INVALID_COMPANY ? nullptr : AIConfig::GetConfig(this->selected_slot);
 

	
 
		this->SetWidgetDisabledState(WID_AIC_DECREASE_NUMBER, GetGameSettings().difficulty.max_no_competitors == 0);
 
		this->SetWidgetDisabledState(WID_AIC_INCREASE_NUMBER, GetGameSettings().difficulty.max_no_competitors == MAX_COMPANIES - 1);
0 comments (0 inline, 0 general)