[Scummvm-cvs-logs] SF.net SVN: scummvm:[50872] scummvm/trunk/engines/m4/converse.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Wed Jul 14 06:42:27 CEST 2010
Revision: 50872
http://scummvm.svn.sourceforge.net/scummvm/?rev=50872&view=rev
Author: eriktorbjorn
Date: 2010-07-14 04:42:27 +0000 (Wed, 14 Jul 2010)
Log Message:
-----------
The new buffer has to be one byte longer than the length of the 'buffer'
string. (Error spotted by cppcheck.) Also, there's no need to use sprintf()
where a strcpy() will do just as well. (It's tempting, but probably not
appropriate, to use strdup(). I'm guessing the buffer *has* to be allocated
with 'new'.)
Modified Paths:
--------------
scummvm/trunk/engines/m4/converse.cpp
Modified: scummvm/trunk/engines/m4/converse.cpp
===================================================================
--- scummvm/trunk/engines/m4/converse.cpp 2010-07-14 04:34:57 UTC (rev 50871)
+++ scummvm/trunk/engines/m4/converse.cpp 2010-07-14 04:42:27 UTC (rev 50872)
@@ -858,8 +858,8 @@
if (buffer[curPos - 1] == '\0') {
// end of string
//printf("%s\n", buffer);
- buf = new char[strlen(buffer)];
- sprintf(buf, "%s", buffer);
+ buf = new char[strlen(buffer) + 1];
+ strcpy(buf, buffer);
_convStrings.push_back(buf);
curPos = 0;
*buffer = 0;
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