From f47393c66bb1810a9916fa755bc5830fb9d24d63 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 1 Sep 2011 21:56:53 +0200 Subject: [PATCH] CTest: Fix memory leaks on error Credit goes to "cppcheck". Signed-off-by: Thomas Jarosch --- Source/CTest/cmCTestRunTest.cxx | 2 ++ Source/CTest/cmParsePHPCoverage.cxx | 1 + Source/cmCTest.cxx | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 60695daa1..81f18b05c 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -93,6 +93,7 @@ void cmCTestRunTest::CompressOutput() ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return; } @@ -106,6 +107,7 @@ void cmCTestRunTest::CompressOutput() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output " "compression. Sending uncompressed output." << std::endl); + delete[] out; return; } diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 32c1ec110..593b2d1a8 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -159,6 +159,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) // read open quote if(in.get(c) && c != '"') { + delete[] s; return false; } // read the string data diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 75a564e78..702ba10ad 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3096,6 +3096,7 @@ bool cmCTest::CompressString(std::string& str) ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return false; } @@ -3109,6 +3110,7 @@ bool cmCTest::CompressString(std::string& str) { cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." << std::endl); + delete[] out; return false; }