mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
Fix access to undefined SlotCount.
This commit is contained in:
parent
dfbdc8ae45
commit
8b14c24c7c
@ -207,17 +207,26 @@ public:
|
|||||||
virtual XBool validate(XmlLiteParser* xmlLiteParser, const XString8& xmlPath, const XmlParserPosition& keyPos, XBool generateErrors) override {
|
virtual XBool validate(XmlLiteParser* xmlLiteParser, const XString8& xmlPath, const XmlParserPosition& keyPos, XBool generateErrors) override {
|
||||||
if ( !super::validate(xmlLiteParser, xmlPath, keyPos, generateErrors) ) return false;
|
if ( !super::validate(xmlLiteParser, xmlPath, keyPos, generateErrors) ) return false;
|
||||||
XBool b = true;
|
XBool b = true;
|
||||||
for ( size_t i = 0 ; i < Modules.size() ; ) {
|
if ( Modules.size() == 0 ) {
|
||||||
if ( Modules[i].SlotIndex.value() >= SlotCount.value() ) {
|
// whatever if SlotCount is defined or not, and whatever value, it's ok.
|
||||||
xmlLiteParser->addWarning(generateErrors, S8Printf("Ignore memory module with slot >= SlotCount at '%s:%d'", xmlPath.c_str(), keyPos.getLine()));
|
return b;
|
||||||
Modules.RemoveAtIndex(i);
|
|
||||||
}else{
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( SlotCount.value() < Modules.dgetCalculatedSlotCount() ) {
|
if ( !SlotCount.isDefined() ) {
|
||||||
log_technical_bug("SlotCount.value() < Modules.dgetCalculatedSlotCount()");
|
xmlLiteParser->addWarning(generateErrors, S8Printf("SlotCount is not defined in SMBIOS, but you defined memory modules. SlotCount adjusted to %d, which maybe wrong.", Modules.dgetCalculatedSlotCount())); // do not set b to false because value is auto-corrected, so it's now ok.
|
||||||
SlotCount.setUInt8Value(Modules.dgetCalculatedSlotCount());
|
SlotCount.setUInt8Value(Modules.dgetCalculatedSlotCount());
|
||||||
|
}else{
|
||||||
|
for ( size_t i = 0 ; i < Modules.size() ; ) {
|
||||||
|
if ( Modules[i].SlotIndex.value() >= SlotCount.value() ) {
|
||||||
|
xmlLiteParser->addWarning(generateErrors, S8Printf("Ignored memory module with slot >= SlotCount at '%s:%d'", xmlPath.c_str(), keyPos.getLine())); // do not set b to false because value is auto-corrected, so it's now ok.
|
||||||
|
Modules.RemoveAtIndex(i);
|
||||||
|
}else{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( SlotCount.value() < Modules.dgetCalculatedSlotCount() ) {
|
||||||
|
log_technical_bug("SlotCount.value() < Modules.dgetCalculatedSlotCount()");
|
||||||
|
SlotCount.setUInt8Value(Modules.dgetCalculatedSlotCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user