[Scummvm-cvs-logs] CVS: scummvm/common gameDetector.cpp,1.3,1.4 scummsys.h,1.3,1.4
Matt Hargett
matt_hargett at users.sourceforge.net
Sat Sep 7 12:56:02 CEST 2002
Update of /cvsroot/scummvm/scummvm/common
In directory usw-pr-cvs1:/tmp/cvs-serv5244/scummvm/common
Modified Files:
gameDetector.cpp scummsys.h
Log Message:
Fix heap corruption. Fix compiler warning.
Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gameDetector.cpp 31 Aug 2002 13:29:09 -0000 1.3
+++ gameDetector.cpp 7 Sep 2002 19:55:16 -0000 1.4
@@ -548,8 +548,10 @@
&& _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)
Index: scummsys.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scummsys.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- scummsys.h 31 Aug 2002 13:12:46 -0000 1.3
+++ scummsys.h 7 Sep 2002 19:55:16 -0000 1.4
@@ -34,6 +34,7 @@
//#pragma warning (disable: 4101)
#define scumm_stricmp stricmp
+#define snprintf _snprintf
#if defined(CHECK_HEAP)
#undef CHECK_HEAP
More information about the Scummvm-git-logs
mailing list