From fca8081a20b7262b9a8b35ce2978feeb033e8144 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Sat, 21 Sep 2024 06:56:32 +0100 Subject: [PATCH] Fix crash when preset amount is too high (#4359) --- soh/soh/Enhancements/presets.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/presets.cpp b/soh/soh/Enhancements/presets.cpp index 57bfd689c..0a2582c4a 100644 --- a/soh/soh/Enhancements/presets.cpp +++ b/soh/soh/Enhancements/presets.cpp @@ -42,7 +42,10 @@ void applyPreset(std::vector 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 ) {