[Cmake-commits] [cmake-commits] david.cole committed cmSystemTools.cxx 1.404 1.405

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Oct 30 10:31:55 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv1448/Source

Modified Files:
	cmSystemTools.cxx 
Log Message:
Fix more mismatched new[] / delete[] (eliminate invalid auto_ptr use) to correct valgrind reported memory issues.


Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.404
retrieving revision 1.405
diff -C 2 -d -r1.404 -r1.405
*** cmSystemTools.cxx	2 Oct 2009 19:30:01 -0000	1.404
--- cmSystemTools.cxx	30 Oct 2009 14:31:51 -0000	1.405
***************
*** 47,51 ****
  #if defined(CMAKE_BUILD_WITH_CMAKE)
  #  include <libtar/libtar.h>
- #  include <memory> // auto_ptr
  #  include <fcntl.h>
  #  include <cm_zlib.h>
--- 47,50 ----
***************
*** 1808,1814 ****
    };
  
!   // Ok, this libtar is not const safe. for now use auto_ptr hack
    char* realName = new char[ strlen(outFileName) + 1 ];
-   std::auto_ptr<char> realNamePtr(realName);
    strcpy(realName, outFileName);
    int options = 0;
--- 1807,1812 ----
    };
  
!   // This libtar is not const safe. Make a non-const copy of outFileName
    char* realName = new char[ strlen(outFileName) + 1 ];
    strcpy(realName, outFileName);
    int options = 0;
***************
*** 1826,1832 ****
--- 1824,1833 ----
      {
      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 )
***************
*** 1860,1863 ****
--- 1861,1865 ----
      return false;
      }
+ 
    return true;
  #else
***************
*** 1887,1893 ****
    };
  
!   // Ok, this libtar is not const safe. for now use auto_ptr hack
    char* realName = new char[ strlen(outFileName) + 1 ];
-   std::auto_ptr<char> realNamePtr(realName);
    strcpy(realName, outFileName);
    if (tar_open(&t, realName,
--- 1889,1894 ----
    };
  
!   // This libtar is not const safe. Make a non-const copy of outFileName
    char* realName = new char[ strlen(outFileName) + 1 ];
    strcpy(realName, outFileName);
    if (tar_open(&t, realName,
***************
*** 1902,1908 ****
--- 1903,1912 ----
      {
      cmSystemTools::Error("Problem with tar_open(): ", strerror(errno));
+     delete [] realName;
      return false;
      }
  
+   delete [] realName;
+ 
    if (tar_extract_all(t, 0) != 0)
    {
***************
*** 1941,1947 ****
    };
  
!   // Ok, this libtar is not const safe. for now use auto_ptr hack
    char* realName = new char[ strlen(outFileName) + 1 ];
-   std::auto_ptr<char> realNamePtr(realName);
    strcpy(realName, outFileName);
    if (tar_open(&t, realName,
--- 1945,1950 ----
    };
  
!   // This libtar is not const safe. Make a non-const copy of outFileName
    char* realName = new char[ strlen(outFileName) + 1 ];
    strcpy(realName, outFileName);
    if (tar_open(&t, realName,
***************
*** 1956,1962 ****
--- 1959,1968 ----
      {
      cmSystemTools::Error("Problem with tar_open(): ", strerror(errno));
+     delete [] realName;
      return false;
      }
  
+   delete [] realName;
+ 
    while ((th_read(t)) == 0)
    {



More information about the Cmake-commits mailing list