From 897aa5d7878e14b9b10343b034b8fbfdef5e2b43 Mon Sep 17 00:00:00 2001
From: Bill Hoffman <bill.hoffman@kitware.com>
Date: Tue, 22 Sep 2009 14:56:33 -0400
Subject: [PATCH] Put a flag in that will stop system tools from deleting
 system environment memory on exit, as it can cause gcov to crash the
 programs.

---
 Configure.hxx.in | 3 +++
 SystemTools.cxx  | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/Configure.hxx.in b/Configure.hxx.in
index 444f46f3..1536e727 100644
--- a/Configure.hxx.in
+++ b/Configure.hxx.in
@@ -17,6 +17,9 @@
 /* Include C configuration.  */
 #include <@KWSYS_NAMESPACE@/Configure.h>
 
+/* Disable cleanup of putenv memory for issues with GCOV */
+#cmakedefine KWSYS_DO_NOT_CLEAN_PUTENV
+
 /* Whether ANSI C++ stream headers are to be used.  */
 #define @KWSYS_NAMESPACE@_IOS_USE_ANSI @KWSYS_IOS_USE_ANSI@
 
diff --git a/SystemTools.cxx b/SystemTools.cxx
index dc9977c8..16683a9f 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -415,11 +415,13 @@ public:
 
 kwsysDeletingCharVector::~kwsysDeletingCharVector()
 {
+#ifndef KWSYS_DO_NOT_CLEAN_PUTENV
   for(kwsys_stl::vector<char*>::iterator i = this->begin();
       i != this->end(); ++i)
     {
     delete []*i;
     }
+#endif
 }
 bool SystemTools::PutEnv(const char* value)
 { 
-- 
GitLab