diff options
author | Matt Hargett | 2002-09-07 19:55:16 +0000 |
---|---|---|
committer | Matt Hargett | 2002-09-07 19:55:16 +0000 |
commit | 0069fb107267705b186fbed098a62a78624855ae (patch) | |
tree | 016bbc79a549b04eb2299f655dc7baa21f2931ee /common | |
parent | 5b4f2cefef465a6d4915527b7f91e782816a1f2b (diff) | |
download | scummvm-rg350-0069fb107267705b186fbed098a62a78624855ae.tar.gz scummvm-rg350-0069fb107267705b186fbed098a62a78624855ae.tar.bz2 scummvm-rg350-0069fb107267705b186fbed098a62a78624855ae.zip |
Fix heap corruption. Fix compiler warning.
svn-id: r4901
Diffstat (limited to 'common')
-rw-r--r-- | common/gameDetector.cpp | 6 | ||||
-rw-r--r-- | common/scummsys.h | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp index 237dbf663f..94e46da0dc 100644 --- a/common/gameDetector.cpp +++ b/common/gameDetector.cpp @@ -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) diff --git a/common/scummsys.h b/common/scummsys.h index 5234c1ceaf..9048a1e3d2 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -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 |