[Scummvm-cvs-logs] SF.net SVN: scummvm: [29678] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Dec 1 11:34:23 CET 2007


Revision: 29678
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29678&view=rev
Author:   dreammaster
Date:     2007-12-01 02:34:22 -0800 (Sat, 01 Dec 2007)

Log Message:
-----------
Fix for Valgrind warning - at least one animation read a single byte beyond the end of the source data just prior to finishing decompression

Modified Paths:
--------------
    scummvm/trunk/engines/lure/decode.cpp
    scummvm/trunk/engines/lure/decode.h

Modified: scummvm/trunk/engines/lure/decode.cpp
===================================================================
--- scummvm/trunk/engines/lure/decode.cpp	2007-12-01 08:15:30 UTC (rev 29677)
+++ scummvm/trunk/engines/lure/decode.cpp	2007-12-01 10:34:22 UTC (rev 29678)
@@ -175,14 +175,19 @@
 #define SET_HI_BYTE(x,v) x = (x & 0xff) | ((v) << 8);
 #define SET_LO_BYTE(x,v) x = (x & 0xff00) | (v);
 
-void AnimationDecoder::decode_data_2(byte *&pSrc, uint16 &currData, uint16 &bitCtr, 
-									 uint16 &dx, bool &carry) {
+void AnimationDecoder::decode_data_2(MemoryBlock *src, byte *&pSrc, uint16 &currData, 
+									 uint16 &bitCtr, uint16 &dx, bool &carry) {
 	SET_HI_BYTE(dx, currData >> 8);
 	
 	for (int v = 0; v < 8; ++v) {
 		rcl(currData, carry);
 		if (--bitCtr == 0) {
-			GET_BYTE;
+			uint32 offset = (uint32) (pSrc - src->data());
+			if (offset >= src->size()) 
+				// Beyond end of source, so read in a 0 value
+				currData &= 0xff00;
+			else
+				GET_BYTE;
 			bitCtr = 8;
 		}
 	}
@@ -285,10 +290,10 @@
 		if (dxHigh == BX_VAL(0)) {
 			tempReg1 = bitCtr;
 			tempReg2 = dx;
-			decode_data_2(pSrc, currData, bitCtr, dx, carry);
+			decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
 		
 			SET_LO_BYTE(dx, dx >> 8);
-			decode_data_2(pSrc, currData, bitCtr, dx, carry);
+			decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
 			SET_HI_BYTE(bitCtr, dx & 0xff);
 			SET_LO_BYTE(bitCtr, dx >> 8);
 			dx = tempReg2;
@@ -299,7 +304,7 @@
 
 		} else if (dxHigh == BX_VAL(0x10)) {
 			tempReg1 = bitCtr;
-			decode_data_2(pSrc, currData, bitCtr, dx, carry);
+			decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
 			bitCtr = dx >> 8;
 
 		} else if (dxHigh == BX_VAL(0x20)) {

Modified: scummvm/trunk/engines/lure/decode.h
===================================================================
--- scummvm/trunk/engines/lure/decode.h	2007-12-01 08:15:30 UTC (rev 29677)
+++ scummvm/trunk/engines/lure/decode.h	2007-12-01 10:34:22 UTC (rev 29678)
@@ -56,8 +56,8 @@
 public:
 	static void rcl(uint16 &value, bool &carry);
 	static uint32 decode_data(MemoryBlock *src, MemoryBlock *dest, uint32 srcPos);
-	static void decode_data_2(byte *&pSrc, uint16 &currData, uint16 &bitCtr,
-					   uint16 &dx, bool &carry);
+	static void decode_data_2(MemoryBlock *src, byte *&pSrc, uint16 &currData, 
+						uint16 &bitCtr, uint16 &dx, bool &carry);
 };
 
 } // End of namespace Lure


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list