Skip to content

Commit

Permalink
CHEWY: Fix undefined behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Oct 7, 2016
1 parent c3a4950 commit 8df9eb5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions engines/chewy/resource.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 8df9eb5

Please sign in to comment.