1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-30 07:42:13 +00:00

ncm: safer access patterns for FirmwareVariationInfo

This commit is contained in:
Michael Scire 2020-07-10 11:49:44 -07:00
parent ad551c3b55
commit faad5609b9

View file

@ -130,7 +130,7 @@ namespace ams::ncm {
} else { } else {
/* Check if the current variation refers to base. */ /* Check if the current variation refers to base. */
const FirmwareVariationInfo *cur_variation_info = extended_data_reader.GetFirmwareVariationInfo(i); const FirmwareVariationInfo *cur_variation_info = extended_data_reader.GetFirmwareVariationInfo(i);
const bool cur_refers_to_base = cur_variation_info->refer_to_base || extended_data_reader.GetHeader()->version == 1; const bool cur_refers_to_base = extended_data_reader.GetHeader()->version == 1 || cur_variation_info->refer_to_base;
/* We force referral to base on unsupported variation only if all supported variations refer to base. */ /* We force referral to base on unsupported variation only if all supported variations refer to base. */
force_refer_to_base &= cur_refers_to_base; force_refer_to_base &= cur_refers_to_base;
@ -150,7 +150,7 @@ namespace ams::ncm {
const FirmwareVariationInfo *variation_info = extended_data_reader.GetFirmwareVariationInfo(*firmware_variation_index); const FirmwareVariationInfo *variation_info = extended_data_reader.GetFirmwareVariationInfo(*firmware_variation_index);
/* Refer to base if variation info says we should, or if version is 1. */ /* Refer to base if variation info says we should, or if version is 1. */
const bool refer_to_base = variation_info->refer_to_base || extended_data_reader.GetHeader()->version == 1; const bool refer_to_base = extended_data_reader.GetHeader()->version == 1 || variation_info->refer_to_base;
R_UNLESS(!refer_to_base, ReadMetaInfoListFromBase()); R_UNLESS(!refer_to_base, ReadMetaInfoListFromBase());
/* Output the content meta count. */ /* Output the content meta count. */