[Scummvm-cvs-logs] SF.net SVN: scummvm: [28203] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Wed Jul 25 22:36:15 CEST 2007


Revision: 28203
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28203&view=rev
Author:   drmccoy
Date:     2007-07-25 13:36:14 -0700 (Wed, 25 Jul 2007)

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

Modified Paths:
--------------
    scummvm/trunk/engines/gob/dataio.h
    scummvm/trunk/engines/gob/game.cpp
    scummvm/trunk/engines/gob/game.h
    scummvm/trunk/engines/gob/game_v2.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp

Modified: scummvm/trunk/engines/gob/dataio.h
===================================================================
--- scummvm/trunk/engines/gob/dataio.h	2007-07-25 20:12:41 UTC (rev 28202)
+++ scummvm/trunk/engines/gob/dataio.h	2007-07-25 20:36:14 UTC (rev 28203)
@@ -35,7 +35,7 @@
 
 #define MAX_FILES	30
 #define MAX_DATA_FILES	8
-#define MAX_SLOT_COUNT	4
+#define MAX_SLOT_COUNT	8
 
 class DataIO {
 public:

Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp	2007-07-25 20:12:41 UTC (rev 28202)
+++ scummvm/trunk/engines/gob/game.cpp	2007-07-25 20:36:14 UTC (rev 28203)
@@ -663,7 +663,7 @@
 	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 @@
 
 	if (handle >= 0) {
 		_vm->_dataIO->closeData(handle);
+
+		if (dataSize)
+			*dataSize = _vm->_dataIO->getDataSize(locTextFile);
+
 		return _vm->_dataIO->getData(locTextFile);
 	}
 	return 0;

Modified: scummvm/trunk/engines/gob/game.h
===================================================================
--- scummvm/trunk/engines/gob/game.h	2007-07-25 20:12:41 UTC (rev 28202)
+++ scummvm/trunk/engines/gob/game.h	2007-07-25 20:36:14 UTC (rev 28203)
@@ -215,7 +215,7 @@
 		
 	int16 adjustKey(int16 key);
 
-	byte *loadLocTexts(void);
+	byte *loadLocTexts(int32 *dataSize = 0);
 	int32 loadTotFile(const char *path);
 	void loadExtTable(void);
 	void loadImFile(void);

Modified: scummvm/trunk/engines/gob/game_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v2.cpp	2007-07-25 20:12:41 UTC (rev 28202)
+++ scummvm/trunk/engines/gob/game_v2.cpp	2007-07-25 20:36:14 UTC (rev 28203)
@@ -134,12 +134,16 @@
 			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 @@
 				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) {

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2007-07-25 20:12:41 UTC (rev 28202)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2007-07-25 20:36:14 UTC (rev 28203)
@@ -1174,6 +1174,10 @@
 
 	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 @@
 	_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;
 }


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