ERR: Fix warnings and memory leak

This commit is contained in:
Andy Cedilnik 2004-08-04 08:50:37 -04:00
parent 2938652cbd
commit 87cab828b6
1 changed files with 30 additions and 23 deletions

View File

@ -122,6 +122,7 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args)
err += errorString;
err += ").";
this->SetError(err.c_str());
delete [] errorString;
return false;
}
@ -152,13 +153,16 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
char **errorString, const cmMakefile *makefile)
{
// check for the different signatures
*errorString = "Unknown arguments specified";
const char *def;
const char *def2;
const char* msg = "Unknown arguments specified";
*errorString = new char[strlen(msg) + 1];
strcpy(*errorString, msg);
// handle empty invocation
if (args.size() < 1)
{
delete [] *errorString;
*errorString = 0;
return false;
}
@ -174,6 +178,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
args[0] == "CMAKE_MINOR_VERSION" &&
args[1] == "MATCHES")
{
delete [] *errorString;
*errorString = 0;
return true;
}
@ -288,6 +293,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
{
cmOStringStream error;
error << "Regular expression \"" << rex << "\" cannot compile";
delete [] *errorString;
*errorString = new char[error.str().size() + 1];
strcpy(*errorString, error.str().c_str());
return false;
@ -511,6 +517,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
// now at the end there should only be one argument left
if (newArgs.size() == 1)
{
delete [] *errorString;
*errorString = 0;
if (*newArgs.begin() == "0")
{