Settings: a knob missing from the key table should not be a crash

The tables are meant to be complete and the drift tests are what say so, but
ForCoreKnob returns no section for an enumerator nobody mapped, and both callers
walked straight into strcmp with it.
This commit is contained in:
Brian Degenhardt
2026-08-16 14:22:00 -07:00
parent a6d1e35748
commit e1f8fb1c56
+6 -1
View File
@@ -206,8 +206,10 @@ bool PerGameOverrideKeys::ClaimsAGameDBSetting(const char* section, const char*
for (u32 i = 0; i < static_cast<u32>(CoreGameDBKnob::MaxCount); i++)
{
// A knob added to the enum but not to the table lands here with no section.
// The drift tests are what catch that; this only keeps it from being a crash.
const CoreKnobKeys keys = ForCoreKnob(static_cast<CoreGameDBKnob>(i));
if (std::strcmp(section, keys.section) != 0)
if (!keys.section || std::strcmp(section, keys.section) != 0)
continue;
for (u32 k = 0; k < keys.count; k++)
@@ -238,6 +240,9 @@ PerGameOverrides ComputePerGameOverrides(const SettingsInterface& game_layer)
for (u32 i = 0; i < static_cast<u32>(CoreGameDBKnob::MaxCount); i++)
{
const PerGameOverrideKeys::CoreKnobKeys keys = PerGameOverrideKeys::ForCoreKnob(static_cast<CoreGameDBKnob>(i));
if (!keys.section)
continue;
for (u32 k = 0; k < keys.count; k++)
{
if (!game_layer.ContainsValue(keys.section, keys.keys[k]))