From 625aca976acac85e85a36f68a3727d2eec785922 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Mon, 18 Jun 2018 07:06:04 +0000 Subject: Full cleanup of env cache when in a PURIFY build. --- generic/tclEnv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/generic/tclEnv.c b/generic/tclEnv.c index c559c69..4a48f65 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -723,10 +723,18 @@ TclFinalizeEnvironment(void) * strings. This may leak more memory that strictly necessary, since some * of the strings may no longer be in the environment. However, * determining which ones are ok to delete is n-squared, and is pretty - * unlikely, so we don't bother. + * unlikely, so we don't bother. However, in the case of DPURIFY, just + * free all strings in the cache. */ + size_t i; + if (env.cache) { +#ifdef PURIFY + for (i = 0; i < env.cacheSize; i++) { + ckfree(env.cache[i]); + } +#endif ckfree(env.cache); env.cache = NULL; env.cacheSize = 0; -- cgit v0.12