From 8df9eb5b8fd5a88a1158f9a6253bd0b18fc52362 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 7 Oct 2016 12:29:14 +0300 Subject: CHEWY: Fix undefined behavior --- engines/chewy/resource.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'engines/chewy') diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp index c1164f193b..e112d98cdb 100644 --- a/engines/chewy/resource.cpp +++ b/engines/chewy/resource.cpp @@ -251,10 +251,11 @@ SoundChunk *SoundResource::getSound(uint num) { // Find the total length of the voice file do { blocksRemaining = _stream.readByte(); - blockSize = - _stream.readByte() + - (_stream.readByte() << 8) + - (_stream.readByte() << 16); + + byte b1 = _stream.readByte(); + byte b2 = _stream.readByte(); + byte b3 = _stream.readByte(); + blockSize = b1 + (b2 << 8) + (b3 << 16); totalLength += blockSize; _stream.skip(blockSize); @@ -269,10 +270,11 @@ SoundChunk *SoundResource::getSound(uint num) { do { blocksRemaining = _stream.readByte(); - blockSize = - _stream.readByte() + - (_stream.readByte() << 8) + - (_stream.readByte() << 16); + + byte b1 = _stream.readByte(); + byte b2 = _stream.readByte(); + byte b3 = _stream.readByte(); + blockSize = b1 + (b2 << 8) + (b3 << 16); _stream.read(ptr, blockSize); ptr += blockSize; -- cgit v1.2.3