aboutsummaryrefslogtreecommitdiff
path: root/engines/lure
diff options
context:
space:
mode:
authorPaul Gilbert2007-12-01 10:34:22 +0000
committerPaul Gilbert2007-12-01 10:34:22 +0000
commit30af5576d7a242ff976e412bf675a355efb072b5 (patch)
treef59ae55e30d50d2385a437ccd5c1565f3b6b78d7 /engines/lure
parent044100c0975babf7f823802f9f7760eccf7d954e (diff)
downloadscummvm-rg350-30af5576d7a242ff976e412bf675a355efb072b5.tar.gz
scummvm-rg350-30af5576d7a242ff976e412bf675a355efb072b5.tar.bz2
scummvm-rg350-30af5576d7a242ff976e412bf675a355efb072b5.zip
Fix for Valgrind warning - at least one animation read a single byte beyond the end of the source data just prior to finishing decompression
svn-id: r29678
Diffstat (limited to 'engines/lure')
-rw-r--r--engines/lure/decode.cpp17
-rw-r--r--engines/lure/decode.h4
2 files changed, 13 insertions, 8 deletions
diff --git a/engines/lure/decode.cpp b/engines/lure/decode.cpp
index dc4bdb95e1..ebc1da4f3f 100644
--- a/engines/lure/decode.cpp
+++ b/engines/lure/decode.cpp
@@ -175,14 +175,19 @@ void AnimationDecoder::rcl(uint16 &value, bool &carry) {
#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 @@ loc_1441:
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 @@ loc_1441:
} 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)) {
diff --git a/engines/lure/decode.h b/engines/lure/decode.h
index ff83ba6454..0f925ab3f0 100644
--- a/engines/lure/decode.h
+++ b/engines/lure/decode.h
@@ -56,8 +56,8 @@ class AnimationDecoder {
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