Fix crash when preset amount is too high (#4359)

This commit is contained in:
Pepper0ni 2024-09-21 06:56:32 +01:00 committed by GitHub
parent 5d8841777a
commit fca8081a20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,10 @@ void applyPreset(std::vector<PresetEntry> entries) {
void DrawPresetSelector(PresetType presetTypeId) {
const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(presetTypeId);
const PresetTypeDefinition presetTypeDef = presetTypes.at(presetTypeId);
const uint16_t selectedPresetId = CVarGetInteger(presetTypeCvar.c_str(), 0);
uint16_t selectedPresetId = CVarGetInteger(presetTypeCvar.c_str(), 0);
if(selectedPresetId >= presetTypeDef.presets.size()){
selectedPresetId = 0;
}
const PresetDefinition selectedPresetDef = presetTypeDef.presets.at(selectedPresetId);
std::string comboboxTooltip = "";
for ( auto iter = presetTypeDef.presets.begin(); iter != presetTypeDef.presets.end(); ++iter ) {