Author: sagamusix
Date: Sat Jul 13 00:34:39 2024
New Revision: 21148
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21148
Log:
[Fix] XM: Don't fingerprint truncated files as "Unknown", caused by trying to read the instrument header size and failing, then jumping back 4 bytes and reading it again (and thus fingerprinting the instrument header size based on the previous sample or pattern data)
Modified:
trunk/OpenMPT/soundlib/Load_xm.cpp
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
==============================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp Fri Jul 12 22:01:00 2024 (r21147)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp Sat Jul 13 00:34:39 2024 (r21148)
@@ -729,6 +729,11 @@
// Reading instruments
for(INSTRUMENTINDEX instr = 1; instr <= m_nInstruments; instr++)
{
+ if(!AllocateInstrument(instr))
+ return false;
+ if(!file.CanRead(4))
+ continue;
+
// First, try to read instrument header length...
uint32 headerSize = file.ReadUint32LE();
if(headerSize == 0)
@@ -791,11 +796,6 @@
}
}
- if(AllocateInstrument(instr) == nullptr)
- {
- continue;
- }
-
instrHeader.ConvertToMPT(*Instruments[instr]);
if(lastInstrType == -1)
|