1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Add cfgOptionValid() check to assert in cfgOptionIdxTest().

Skip the rest of the assert if the option is not valid since this function is intended to work with invalid options.
This commit is contained in:
David Steele 2021-01-15 08:59:16 -05:00
parent 7f263dceb7
commit 38583b6414

View File

@ -1206,9 +1206,10 @@ cfgOptionIdxTest(ConfigOption optionId, unsigned int optionIdx)
ASSERT(optionId < CFG_OPTION_TOTAL);
ASSERT(configLocal != NULL);
ASSERT(
(!configLocal->option[optionId].group && optionIdx == 0) ||
(configLocal->option[optionId].group && optionIdx <
configLocal->optionGroup[configLocal->option[optionId].groupId].indexTotal));
!cfgOptionValid(optionId) ||
((!configLocal->option[optionId].group && optionIdx == 0) ||
(configLocal->option[optionId].group && optionIdx <
configLocal->optionGroup[configLocal->option[optionId].groupId].indexTotal)));
FUNCTION_TEST_RETURN(cfgOptionValid(optionId) && configLocal->option[optionId].index[optionIdx].value != NULL);
}