From 7a013b7e8b963c3d7e59b3da9c4d05185ebe910f Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2018 23:54:38 +0200 Subject: [PATCH] SOUND: Force alignment of IMA ADPCM stream size to block size This decoder can't cope with unaligned input. --- src/sound/decoders/adpcm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sound/decoders/adpcm.cpp b/src/sound/decoders/adpcm.cpp index 48a427cf..3d13d98c 100644 --- a/src/sound/decoders/adpcm.cpp +++ b/src/sound/decoders/adpcm.cpp @@ -256,7 +256,8 @@ size_t Apple_ADPCMStream::readBuffer(int16 *buffer, const size_t numSamples) { class MSIma_ADPCMStream : public Ima_ADPCMStream { public: MSIma_ADPCMStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) - : Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { + : Ima_ADPCMStream(stream, disposeAfterUse, size - (size % ((blockAlign == 0) ? 1 : blockAlign)), + rate, channels, blockAlign) { if (blockAlign == 0) error("MSIma_ADPCMStream(): blockAlign isn't specified");