Fix heap corruption. Fix compiler warning.

svn-id: r4901
This commit is contained in:
Matt Hargett 2002-09-07 19:55:16 +00:00
parent 5b4f2cefef
commit 0069fb1072
3 changed files with 6 additions and 3 deletions

View File

@ -548,8 +548,10 @@ int GameDetector::detectMain(int argc, char **argv)
&& _gameDataPath[strlen(_gameDataPath)-1] != '\\') {
char slashless[1024]; /* Append slash to path */
strcpy(slashless, _gameDataPath);
_gameDataPath = (char *)malloc((strlen(slashless) + 1) * sizeof(char));
sprintf(_gameDataPath, "%s/", slashless);
// need to allocate 2 extra bytes, one for the "/" and one for the NULL terminator
_gameDataPath = (char *)malloc((strlen(slashless) + 2) * sizeof(char));
snprintf(_gameDataPath, strlen(_gameDataPath), "%s/", slashless);
}
if (_amiga)

View File

@ -34,6 +34,7 @@ const bool true(1), false(0);
//#pragma warning (disable: 4101)
#define scumm_stricmp stricmp
#define snprintf _snprintf
#if defined(CHECK_HEAP)
#undef CHECK_HEAP

View File

@ -2973,7 +2973,7 @@ void Scumm::o6_kernelFunction()
push(a->frame);
break;
case 215:
if (_extraBoxFlags[args[1]] & 0x00FF == 0x00C0) {
if ((_extraBoxFlags[args[1]] & 0x00FF) == 0x00C0) {
push(_extraBoxFlags[args[1]]);
} else {
byte *temp = (byte *)getBoxBaseAddr(args[1]);