diff options
author | Travis Howell | 2005-02-26 04:53:43 +0000 |
---|---|---|
committer | Travis Howell | 2005-02-26 04:53:43 +0000 |
commit | 1d23aada61b1415e0336495f277f4cc9c9315bc8 (patch) | |
tree | eb1538d0c9870d534490a02c1dc44431faa709d3 | |
parent | 6d7935cc6bc999975ebc0b26656f26435c775fa8 (diff) | |
download | scummvm-rg350-1d23aada61b1415e0336495f277f4cc9c9315bc8.tar.gz scummvm-rg350-1d23aada61b1415e0336495f277f4cc9c9315bc8.tar.bz2 scummvm-rg350-1d23aada61b1415e0336495f277f4cc9c9315bc8.zip |
Catch all invalid image resource reads
svn-id: r16924
-rw-r--r-- | scumm/sprite_he.cpp | 7 | ||||
-rw-r--r-- | scumm/wiz_he.cpp | 12 |
2 files changed, 10 insertions, 9 deletions
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp index 08b99b49eb..a2b4c907b6 100644 --- a/scumm/sprite_he.cpp +++ b/scumm/sprite_he.cpp @@ -314,7 +314,12 @@ int ScummEngine_v90he::spriteInfoGet_field_88(int spriteId, int type) { void ScummEngine_v90he::getSpriteImageDim(int spriteId, int32 &w, int32 &h) { checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d"); - getWizImageDim(_spriteTable[spriteId].res_id, _spriteTable[spriteId].res_state, w, h); + if (_spriteTable[spriteId].res_id) { + getWizImageDim(_spriteTable[spriteId].res_id, _spriteTable[spriteId].res_state, w, h); + } else { + w = 0; + h = 0; + } } void ScummEngine_v90he::spriteInfoGet_tx_ty(int spriteId, int32 &tx, int32 &ty) { diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp index 78e18f2e00..a7b6f75e7f 100644 --- a/scumm/wiz_he.cpp +++ b/scumm/wiz_he.cpp @@ -843,14 +843,10 @@ void ScummEngine_v72he::displayWizImage(const WizImage *pwi) { void ScummEngine_v72he::getWizImageDim(int resnum, int state, int32 &w, int32 &h) { const uint8 *dataPtr = getResourceAddress(rtImage, resnum); - if (dataPtr) { - const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0); - w = READ_LE_UINT32(wizh + 0x4); - h = READ_LE_UINT32(wizh + 0x8); - } else { - w = 0; - h = 0; - } + assert(dataPtr); + const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0); + w = READ_LE_UINT32(wizh + 0x4); + h = READ_LE_UINT32(wizh + 0x8); } uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) { |