Subject: [4dbdd9af14] Proposed fix for mem leak.

From: dgp <[email-masked]>
Date: Tue, 6 Sep 2016 20:30:07 +0000

---
 generic/tclVar.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/generic/tclVar.c b/generic/tclVar.c
index bdc64b7..55eb91c 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -4498,7 +4498,6 @@ TclDeleteNamespaceVars(
 	Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, objPtr);
 	UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
 		NULL, flags);
-	Tcl_DecrRefCount(objPtr); /* free no longer needed obj */
 
 	/*
 	 * Remove the variable from the table and force it undefined in case
@@ -4527,6 +4526,12 @@ TclDeleteNamespaceVars(
 		}
 	    }
 	}
+
+	if (!TclIsVarUndefined(varPtr)) {
+	    UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
+		    NULL, flags);
+	}
+	Tcl_DecrRefCount(objPtr); /* free no longer needed obj */
 	VarHashRefCount(varPtr)--;
 	VarHashDeleteEntry(varPtr);
     }
-- 
cgit v0.12