mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
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:
@@ -206,8 +206,10 @@ bool PerGameOverrideKeys::ClaimsAGameDBSetting(const char* section, const char*
|
|||||||
|
|
||||||
for (u32 i = 0; i < static_cast<u32>(CoreGameDBKnob::MaxCount); i++)
|
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));
|
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;
|
continue;
|
||||||
|
|
||||||
for (u32 k = 0; k < keys.count; k++)
|
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++)
|
for (u32 i = 0; i < static_cast<u32>(CoreGameDBKnob::MaxCount); i++)
|
||||||
{
|
{
|
||||||
const PerGameOverrideKeys::CoreKnobKeys keys = PerGameOverrideKeys::ForCoreKnob(static_cast<CoreGameDBKnob>(i));
|
const PerGameOverrideKeys::CoreKnobKeys keys = PerGameOverrideKeys::ForCoreKnob(static_cast<CoreGameDBKnob>(i));
|
||||||
|
if (!keys.section)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (u32 k = 0; k < keys.count; k++)
|
for (u32 k = 0; k < keys.count; k++)
|
||||||
{
|
{
|
||||||
if (!game_layer.ContainsValue(keys.section, keys.keys[k]))
|
if (!game_layer.ContainsValue(keys.section, keys.keys[k]))
|
||||||
|
|||||||
Reference in New Issue
Block a user