Skip to content

Commit

Permalink
Merged revision(s) 20675 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Imp] DMF: Avoid spending a lot of time on reading non-existing pattern data.
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.30@20677 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Apr 28, 2024
1 parent ce85dfd commit 721066d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion soundlib/Load_dmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static PATTERNINDEX ConvertDMFPattern(FileReader &file, const uint8 fileVersion,
// Counters for channel packing (including global track)
std::vector<uint8> channelCounter(numChannels + 1, 0);

for(ROWINDEX row = 0; row < numRows; row++)
for(ROWINDEX row = 0; row < numRows && file.CanRead(1); row++)
{
// Global track info counter reached 0 => read global track data
if(channelCounter[0] == 0)
Expand Down Expand Up @@ -973,6 +973,8 @@ bool CSoundFile::ReadDMF(FileReader &file, ModLoadingFlags loadFlags)
const uint8 headerSize = fileHeader.version < 3 ? 9 : 8;
chunk.Skip(headerSize - sizeof(uint32le));
const uint32 patLength = chunk.ReadUint32LE();
if(!chunk.CanRead(patLength))
return false;
chunk.SkipBack(headerSize);
patternChunk = chunk.ReadChunk(headerSize + patLength);
}
Expand Down

0 comments on commit 721066d

Please sign in to comment.