diff options
author | David Cole <david.cole@kitware.com> | 2009-10-26 17:49:20 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-10-26 17:49:20 (GMT) |
commit | e0bbaa889a65afb922de8cf617b64a8629920cc2 (patch) | |
tree | b588b4951040029e1f4e7ec93a56c7042a02c0ec | |
parent | 0b8837814afb82547d4c78d153db1fd7b1b34cfe (diff) | |
download | CMake-e0bbaa889a65afb922de8cf617b64a8629920cc2.zip CMake-e0bbaa889a65afb922de8cf617b64a8629920cc2.tar.gz CMake-e0bbaa889a65afb922de8cf617b64a8629920cc2.tar.bz2 |
Correct one of the valgrind errors from the CPackTestAllGenerators test. Do not use auto_ptr on a new [] allocation because auto_ptr does not use delete [].
-rw-r--r-- | Source/CPack/cmCPackTGZGenerator.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 1c56d81..391093a 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -23,7 +23,6 @@ #include <cmsys/SystemTools.hxx> #include <cm_zlib.h> #include <libtar/libtar.h> -#include <memory> // auto_ptr #include <fcntl.h> #include <errno.h> @@ -219,9 +218,8 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, &mydata }; - // Ok, this libtar is not const safe. for now use auto_ptr hack + // Ok, 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 flags = O_WRONLY | O_CREAT; int options = 0; @@ -239,6 +237,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): " << strerror(errno) << std::endl); + delete [] realName; return 0; } @@ -257,6 +256,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, << pathname << "\"): " << strerror(errno) << std::endl); tar_close(t); + delete [] realName; return 0; } } @@ -265,6 +265,7 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_append_eof(): " << strerror(errno) << std::endl); tar_close(t); + delete [] realName; return 0; } @@ -272,8 +273,10 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_close(): " << strerror(errno) << std::endl); + delete [] realName; return 0; } + delete [] realName; return 1; } |