[Scummvm-cvs-logs] scummvm master -> 21ed47ce1366ee6b9b861391faeccc0eb2c5afb3

eriktorbjorn eriktorbjorn at telia.com
Mon Feb 18 20:16:41 CET 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
21ed47ce13 VIDEO: Fix Smacker crash, as per madmoose's suggestion


Commit: 21ed47ce1366ee6b9b861391faeccc0eb2c5afb3
    https://github.com/scummvm/scummvm/commit/21ed47ce1366ee6b9b861391faeccc0eb2c5afb3
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2013-02-18T11:12:35-08:00

Commit Message:
VIDEO: Fix Smacker crash, as per madmoose's suggestion

Apparently, in some movies the Smacker decoder would peek ahead
past the end of the bitstream, even though it didn't necessarily
use all of those bits later. Fix that by first checking how many
bits are still available. (This was originally reported for the
mg1shoot.smk cutscene in the 4 CD version of The Feeble Files.)

Changed paths:
    NEWS
    video/smk_decoder.cpp



diff --git a/NEWS b/NEWS
index 0ae4155..f5c4f88 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ For a more comprehensive changelog of the latest experimental code, see:
      change it at all.
    - Updated MT-32 emulation code to latest munt project snapshot.
    - Added FluidSynth settings dialog, mainly for reverb and chorus settings.
+   - Fixed crash on certain Smacker movies.
 
   Cine:
    - Improved audio support for Amiga and AtariST versions of Future Wars.
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index c497911..4e18268 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -119,7 +119,7 @@ uint16 SmallHuffmanTree::decodeTree(uint32 prefix, int length) {
 }
 
 uint16 SmallHuffmanTree::getCode(Common::BitStream &bs) {
-	byte peek = bs.peekBits(8);
+	byte peek = bs.peekBits(MIN<uint32>(bs.size() - bs.pos(), 8));
 	uint16 *p = &_tree[_prefixtree[peek]];
 	bs.skip(_prefixlength[peek]);
 
@@ -257,7 +257,7 @@ uint32 BigHuffmanTree::decodeTree(uint32 prefix, int length) {
 }
 
 uint32 BigHuffmanTree::getCode(Common::BitStream &bs) {
-	byte peek = bs.peekBits(8);
+	byte peek = bs.peekBits(MIN<uint32>(bs.size() - bs.pos(), 8));
 	uint32 *p = &_tree[_prefixtree[peek]];
 	bs.skip(_prefixlength[peek]);
 






More information about the Scummvm-git-logs mailing list