From 1d23aada61b1415e0336495f277f4cc9c9315bc8 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 26 Feb 2005 04:53:43 +0000 Subject: [PATCH] Catch all invalid image resource reads svn-id: r16924 --- scumm/sprite_he.cpp | 7 ++++++- 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 08b99b49eba..a2b4c907b67 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 78e18f2e005..a7b6f75e7fa 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) {