From 51c380ef8bb6f075cb07c12265447eaf5f67e0a4 Mon Sep 17 00:00:00 2001
From: "dbaron@dbaron.org" <dbaron@dbaron.org>
Date: Fri, 10 Aug 2007 14:30:13 -0700
Subject: [PATCH] Finish the deflated string cache after uninterning atoms, so
 we don't leak their associated strings.  b=391587  r+a=brendan

---
 js/src/jsapi.c   | 6 ++++++
 js/src/jscntxt.c | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/js/src/jsapi.c b/js/src/jsapi.c
index b3fe61cece169..ba9a79e041822 100644
--- a/js/src/jsapi.c
+++ b/js/src/jsapi.c
@@ -767,6 +767,12 @@ JS_DestroyRuntime(JSRuntime *rt)
 
     js_FreeRuntimeScriptState(rt);
     js_FinishAtomState(rt);
+
+    /*
+     * Finish the deflated string cache after the last GC and after
+     * calling js_FinishAtomState, which finalizes strings.
+     */
+    js_FinishDeflatedStringCache(rt);
     js_FinishGC(rt);
 #ifdef JS_THREADSAFE
     if (rt->gcLock)
diff --git a/js/src/jscntxt.c b/js/src/jscntxt.c
index 27c6a60f259eb..58d76fae7e0ff 100644
--- a/js/src/jscntxt.c
+++ b/js/src/jscntxt.c
@@ -409,12 +409,6 @@ js_DestroyContext(JSContext *cx, JSDestroyContextMode mode)
         if (rt->scriptFilenameTable && rt->scriptFilenameTable->nentries == 0)
             js_FinishRuntimeScriptState(rt);
 
-        /*
-         * Free the deflated string cache, but only after the last GC has
-         * collected all unleaked strings.
-         */
-        js_FinishDeflatedStringCache(rt);
-
         /*
          * Free unit string storage only after the last GC has completed, so
          * that js_FinalizeStringRT can detect unit strings and avoid calling
-- 
GitLab