Added a few safety checks. Now Woodruff shows the loading image (closely followed by a crash).

svn-id: r28203
This commit is contained in:
Sven Hesse 2007-07-25 20:36:14 +00:00
parent d0780a5954
commit 99a707d89e
5 changed files with 21 additions and 5 deletions

View File

@ -35,7 +35,7 @@ namespace Gob {
#define MAX_FILES 30
#define MAX_DATA_FILES 8
#define MAX_SLOT_COUNT 4
#define MAX_SLOT_COUNT 8
class DataIO {
public:

View File

@ -663,7 +663,7 @@ int16 Game::openLocTextFile(char *locTextFile, int language) {
return _vm->_dataIO->openData(locTextFile);
}
byte *Game::loadLocTexts(void) {
byte *Game::loadLocTexts(int32 *dataSize) {
char locTextFile[20];
int16 handle;
int i;
@ -689,6 +689,10 @@ byte *Game::loadLocTexts(void) {
if (handle >= 0) {
_vm->_dataIO->closeData(handle);
if (dataSize)
*dataSize = _vm->_dataIO->getDataSize(locTextFile);
return _vm->_dataIO->getData(locTextFile);
}
return 0;

View File

@ -215,7 +215,7 @@ protected:
int16 adjustKey(int16 key);
byte *loadLocTexts(void);
byte *loadLocTexts(int32 *dataSize = 0);
int32 loadTotFile(const char *path);
void loadExtTable(void);
void loadImFile(void);

View File

@ -134,12 +134,16 @@ void Game_v2::playTot(int16 skipPlay) {
totTextLoc = false;
if (READ_LE_UINT32(filePtr) != (uint32) -1) {
_totTextData = new TotTextTable;
int32 size;
if (READ_LE_UINT32(filePtr) == 0) {
_totTextData->dataPtr = loadLocTexts();
_totTextData->dataPtr = loadLocTexts(&size);
totTextLoc = true;
} else {
_totTextData->dataPtr =
(_totFileData + READ_LE_UINT32(_totFileData + 0x30));
size = totSize;
_vm->_global->_language = _vm->_global->_languageWanted;
}
@ -147,7 +151,7 @@ void Game_v2::playTot(int16 skipPlay) {
if (_totTextData->dataPtr != 0) {
Common::MemoryReadStream totTextData(_totTextData->dataPtr,
4294967295U);
_totTextData->itemsCount = totTextData.readSint16LE();
_totTextData->itemsCount = MIN<int32>(totTextData.readSint16LE(), (size - 2) / 4);
_totTextData->items = new TotTextItem[_totTextData->itemsCount];
for (int i = 0; i < _totTextData->itemsCount; ++i) {

View File

@ -1174,6 +1174,10 @@ bool Inter_v1::o1_loadCursor(OpFuncParams &params) {
id = load16();
index = (int8) *_vm->_global->_inter_execPtr++;
if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
return false;
itemPtr = &_vm->_game->_totResourceTable->items[id];
offset = itemPtr->offset;
@ -1896,6 +1900,10 @@ bool Inter_v1::o1_fillRect(OpFuncParams &params) {
_vm->_draw->_spriteBottom = _vm->_parse->parseValExpr();
_vm->_draw->_backColor = _vm->_parse->parseValExpr();
if (!_vm->_draw->_spritesArray[_vm->_draw->_destSurface])
return false;
_vm->_draw->spriteOperation(DRAW_FILLRECT);
return false;
}