diff options
author | David Cole <david.cole@kitware.com> | 2009-10-30 14:31:54 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-10-30 14:31:54 (GMT) |
commit | 43d07f6620df4ab98f1cff56c0c2cc5262df08e0 (patch) | |
tree | 20f9a909c842ee9334afa253b01588d9deeb1220 /Source/cmSystemTools.cxx | |
parent | 5c594b6f3a76542de13dcae1974689b21e7f25c2 (diff) | |
download | CMake-43d07f6620df4ab98f1cff56c0c2cc5262df08e0.zip CMake-43d07f6620df4ab98f1cff56c0c2cc5262df08e0.tar.gz CMake-43d07f6620df4ab98f1cff56c0c2cc5262df08e0.tar.bz2 |
Fix more mismatched new[] / delete[] (eliminate invalid auto_ptr use) to correct valgrind reported memory issues.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 219c1ef..031bfc3 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -46,7 +46,6 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include <libtar/libtar.h> -# include <memory> // auto_ptr # include <fcntl.h> # include <cm_zlib.h> # include <cmsys/MD5.h> @@ -1807,9 +1806,8 @@ bool cmSystemTools::CreateTar(const char* outFileName, &gzs }; - // Ok, this libtar is not const safe. for now use auto_ptr hack + // This libtar is not const safe. Make a non-const copy of outFileName char* realName = new char[ strlen(outFileName) + 1 ]; - std::auto_ptr<char> realNamePtr(realName); strcpy(realName, outFileName); int options = 0; if(verbose) @@ -1825,9 +1823,12 @@ bool cmSystemTools::CreateTar(const char* outFileName, options) == -1) { cmSystemTools::Error("Problem with tar_open(): ", strerror(errno)); + delete [] realName; return false; } + delete [] realName; + std::vector<cmStdString>::const_iterator it; for (it = files.begin(); it != files.end(); ++ it ) { @@ -1859,6 +1860,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, cmSystemTools::Error("Problem with tar_close(): ", strerror(errno)); return false; } + return true; #else (void)outFileName; @@ -1886,9 +1888,8 @@ bool cmSystemTools::ExtractTar(const char* outFileName, &gzs }; - // Ok, this libtar is not const safe. for now use auto_ptr hack + // This libtar is not const safe. Make a non-const copy of outFileName char* realName = new char[ strlen(outFileName) + 1 ]; - std::auto_ptr<char> realNamePtr(realName); strcpy(realName, outFileName); if (tar_open(&t, realName, (gzip? &gztype : NULL), @@ -1901,9 +1902,12 @@ bool cmSystemTools::ExtractTar(const char* outFileName, | 0) == -1) { cmSystemTools::Error("Problem with tar_open(): ", strerror(errno)); + delete [] realName; return false; } + delete [] realName; + if (tar_extract_all(t, 0) != 0) { cmSystemTools::Error("Problem with tar_extract_all(): ", strerror(errno)); @@ -1940,9 +1944,8 @@ bool cmSystemTools::ListTar(const char* outFileName, &gzs }; - // Ok, this libtar is not const safe. for now use auto_ptr hack + // This libtar is not const safe. Make a non-const copy of outFileName char* realName = new char[ strlen(outFileName) + 1 ]; - std::auto_ptr<char> realNamePtr(realName); strcpy(realName, outFileName); if (tar_open(&t, realName, (gzip? &gztype : NULL), @@ -1955,9 +1958,12 @@ bool cmSystemTools::ListTar(const char* outFileName, | 0) == -1) { cmSystemTools::Error("Problem with tar_open(): ", strerror(errno)); + delete [] realName; return false; } + delete [] realName; + while ((th_read(t)) == 0) { const char* filename = th_get_pathname(t); |