Merge topic 'fix-errors-from-cppcheck-issue-12440'

d1751fb ccmake: Fix off-by-one memory access error
4868921 Fix file() command descriptor leak on error
f47393c CTest: Fix memory leaks on error
This commit is contained in:
David Cole 2011-09-07 15:37:48 -04:00 committed by CMake Topic Stage
commit f62540adcc
5 changed files with 8 additions and 1 deletions

View File

@ -93,6 +93,7 @@ void cmCTestRunTest::CompressOutput()
ret = deflateInit(&strm, -1); //default compression level ret = deflateInit(&strm, -1); //default compression level
if (ret != Z_OK) if (ret != Z_OK)
{ {
delete[] out;
return; return;
} }
@ -106,6 +107,7 @@ void cmCTestRunTest::CompressOutput()
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output " cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output "
"compression. Sending uncompressed output." << std::endl); "compression. Sending uncompressed output." << std::endl);
delete[] out;
return; return;
} }

View File

@ -159,6 +159,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in)
// read open quote // read open quote
if(in.get(c) && c != '"') if(in.get(c) && c != '"')
{ {
delete[] s;
return false; return false;
} }
// read the string data // read the string data

View File

@ -68,7 +68,7 @@ void cmCursesLongMessageForm::UpdateStatusBar()
} }
else else
{ {
width = cmCursesMainForm::MAX_WIDTH; width = cmCursesMainForm::MAX_WIDTH-1;
} }
bar[width] = '\0'; bar[width] = '\0';

View File

@ -3096,6 +3096,7 @@ bool cmCTest::CompressString(std::string& str)
ret = deflateInit(&strm, -1); //default compression level ret = deflateInit(&strm, -1); //default compression level
if (ret != Z_OK) if (ret != Z_OK)
{ {
delete[] out;
return false; return false;
} }
@ -3109,6 +3110,7 @@ bool cmCTest::CompressString(std::string& str)
{ {
cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression."
<< std::endl); << std::endl);
delete[] out;
return false; return false;
} }

View File

@ -2982,6 +2982,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::string errStr = "UPLOAD cannot stat file '"; std::string errStr = "UPLOAD cannot stat file '";
errStr += filename + "'."; errStr += filename + "'.";
this->SetError(errStr.c_str()); this->SetError(errStr.c_str());
fclose(fin);
return false; return false;
} }
@ -2991,6 +2992,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if(!curl) if(!curl)
{ {
this->SetError("UPLOAD error initializing curl."); this->SetError("UPLOAD error initializing curl.");
fclose(fin);
return false; return false;
} }