fix possible hang when loading invalid MA/Ox feat

in instrument

issue #2021
This commit is contained in:
tildearrow 2024-07-13 17:01:35 -05:00
parent 6288e18a7a
commit d769264e25

View file

@ -1490,6 +1490,12 @@ void DivInstrument::readFeatureMA(SafeReader& reader, short version) {
unsigned short macroHeaderLen=reader.readS(); unsigned short macroHeaderLen=reader.readS();
if (macroHeaderLen==0) {
logW("invalid macro header length!");
READ_FEAT_END;
return;
}
DivInstrumentMacro* target=&std.volMacro; DivInstrumentMacro* target=&std.volMacro;
while (reader.tell()<endOfFeat) { while (reader.tell()<endOfFeat) {
@ -1716,6 +1722,12 @@ void DivInstrument::readFeatureOx(SafeReader& reader, int op, short version) {
unsigned short macroHeaderLen=reader.readS(); unsigned short macroHeaderLen=reader.readS();
if (macroHeaderLen==0) {
logW("invalid macro header length!");
READ_FEAT_END;
return;
}
DivInstrumentMacro* target=&std.opMacros[op].amMacro; DivInstrumentMacro* target=&std.opMacros[op].amMacro;
while (reader.tell()<endOfFeat) { while (reader.tell()<endOfFeat) {