[Scummvm-cvs-logs] SF.net SVN: scummvm:[53778] scummvm/trunk/engines/lastexpress/debug.cpp
littleboy at users.sourceforge.net
littleboy at users.sourceforge.net
Mon Oct 25 00:15:36 CEST 2010
Revision: 53778
http://scummvm.svn.sourceforge.net/scummvm/?rev=53778&view=rev
Author: littleboy
Date: 2010-10-24 22:15:36 +0000 (Sun, 24 Oct 2010)
Log Message:
-----------
LASTEXPRESS: Fix issues when copying debugger commands
- Properly free allocated memory in resetCommand()
- Make sure _commandParams strings are null-terminated
Modified Paths:
--------------
scummvm/trunk/engines/lastexpress/debug.cpp
Modified: scummvm/trunk/engines/lastexpress/debug.cpp
===================================================================
--- scummvm/trunk/engines/lastexpress/debug.cpp 2010-10-24 22:15:25 UTC (rev 53777)
+++ scummvm/trunk/engines/lastexpress/debug.cpp 2010-10-24 22:15:36 UTC (rev 53778)
@@ -101,11 +101,10 @@
DebugMan.clearAllDebugChannels();
delete _soundStream;
+ resetCommand();
// Zero passed pointers
_engine = NULL;
- _command = NULL;
- _commandParams = NULL;
}
//////////////////////////////////////////////////////////////////////////
@@ -116,7 +115,11 @@
}
void Debugger::resetCommand() {
- _command = NULL;
+ SAFE_DELETE(_command);
+ for (int i = 0; i < _numParams; i++)
+ free(_commandParams[i]);
+
+ free(_commandParams);
_commandParams = NULL;
_numParams = 0;
}
@@ -126,15 +129,15 @@
}
void Debugger::copyCommand(int argc, const char **argv) {
- _commandParams = (char **)malloc((uint)argc);
+ _commandParams = (char **)malloc(sizeof(char *) * argc);
if (!_commandParams)
return;
_numParams = argc;
for (int i = 0; i < _numParams; i++) {
- _commandParams[i] = (char *)malloc(strlen(argv[i]));
- strcpy(_commandParams[i], "");
+ _commandParams[i] = (char *)malloc(strlen(argv[i]) + 1);
+ memset(_commandParams[i], NULL, strlen(argv[i]) + 1);
strcpy(_commandParams[i], argv[i]);
}
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