From e0bbaa889a65afb922de8cf617b64a8629920cc2 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 26 Oct 2009 13:49:20 -0400 Subject: [PATCH] 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 []. --- Source/CPack/cmCPackTGZGenerator.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 1c56d81a9..391093a6f 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -23,7 +23,6 @@ #include #include #include -#include // auto_ptr #include #include @@ -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 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; }