|
From: <sv...@op...> - 2026-10-25 17:04:49
|
Author: sagamusix Date: Sun Oct 25 18:04:42 2026 New Revision: 25812 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=25812 Log: [Fix] WAV: Also sanitize IMA ADPCM sample length for mono samples. Modified: trunk/OpenMPT/soundlib/WAVTools.cpp Modified: trunk/OpenMPT/soundlib/WAVTools.cpp ============================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp Sun Oct 25 18:01:26 2026 (r25811) +++ trunk/OpenMPT/soundlib/WAVTools.cpp Sun Oct 25 18:04:42 2026 (r25812) @@ -107,7 +107,7 @@ // "fact" chunk should contain sample length of compressed samples. sampleLength = chunks.GetChunk(RIFFChunk::idfact).ReadUint32LE(); - if((formatInfo.format == WAVFormatChunk::fmtIMA_ADPCM) && (GetBlockAlign() > 0)) + if((formatInfo.format == WAVFormatChunk::fmtIMA_ADPCM) && (GetBlockAlign() > 4 * formatInfo.numChannels)) { FileReader::pos_type dataLength = sampleData.GetLength(); std::size_t blocks = mpt::align_up<FileReader::pos_type>(dataLength, GetBlockAlign()) / GetBlockAlign(); @@ -123,8 +123,8 @@ { sampleLength *= 2; } - LimitMax(sampleLength, expectedLengthFrames); } + LimitMax(sampleLength, expectedLengthFrames); } if((formatInfo.format != WAVFormatChunk::fmtIMA_ADPCM || sampleLength == 0) && GetSampleSize() != 0) |