From fdc88b9a1be8cdd3d3e98406f244edfec6050771 Mon Sep 17 00:00:00 2001
From: pooryorick <com.digitalsmarties@pooryorick.com>
Date: Mon, 18 Jun 2018 05:59:22 +0000
Subject: [PATCH 1260/1800] Plug leak in TclSetEnv.

---
 generic/tclEnv.c   | 4 ++++
 tests/pkgIndex.tcl | 8 ++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 8cc4b746a..c559c69b8 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -730,6 +730,10 @@ TclFinalizeEnvironment(void)
 	ckfree(env.cache);
 	env.cache = NULL;
 	env.cacheSize = 0;
+	if ((env.ourEnviron != NULL)) {
+	    ckfree(env.ourEnviron);
+	    env.ourEnviron = NULL;
+	}
 #ifndef USE_PUTENV
 	env.ourEnvironSize = 0;
 #endif
diff --git a/tests/pkgIndex.tcl b/tests/pkgIndex.tcl
index 48ab71b73..0feb0eb38 100644
--- a/tests/pkgIndex.tcl
+++ b/tests/pkgIndex.tcl
@@ -1,6 +1,6 @@
 #! /usr/bin/env tclsh
 
-package ifneeded tcltests 0.1 {
-	source [file dirname [file dirname [file normalize [info script]/...]]]/tcltests.tcl
-	package provide tcltests 0.1
-}
+package ifneeded tcltests 0.1 "
+    source [list $dir]/tcltests.tcl
+    package provide tcltests 0.1
+"
-- 
2.19.1

