[Cocoa] JSWrapperMap leaks for all JSContexts
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 22:24:11 +0000 (22:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 22:24:11 +0000 (22:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173110
<rdar://problem/32602198>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-06-08
Reviewed by Geoffrey Garen.

* API/JSContext.mm:
(-[JSContext ensureWrapperMap]):
Ensure this allocation gets released.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217952 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/API/JSContext.mm
Source/JavaScriptCore/ChangeLog

index a9e3666..5b100c7 100644 (file)
 
 - (void)ensureWrapperMap
 {
-    if (!toJS([self JSGlobalContextRef])->lexicalGlobalObject()->wrapperMap())
-        [[JSWrapperMap alloc] initWithGlobalContextRef:[self JSGlobalContextRef]];
+    if (!toJS([self JSGlobalContextRef])->lexicalGlobalObject()->wrapperMap()) {
+        // The map will be retained by the GlobalObject in initialization.
+        [[[JSWrapperMap alloc] initWithGlobalContextRef:[self JSGlobalContextRef]] release];
+    }
 }
 
 - (instancetype)init
index 5d4a1cf..15f457d 100644 (file)
@@ -1,3 +1,15 @@
+2017-06-08  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [Cocoa] JSWrapperMap leaks for all JSContexts
+        https://bugs.webkit.org/show_bug.cgi?id=173110
+        <rdar://problem/32602198>
+
+        Reviewed by Geoffrey Garen.
+
+        * API/JSContext.mm:
+        (-[JSContext ensureWrapperMap]):
+        Ensure this allocation gets released.
+
 2017-06-08  Filip Pizlo  <fpizlo@apple.com>
 
         REGRESSION: js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-5.html has a flaky failure