Title: [249885] trunk/Source/_javascript_Core
- Revision
- 249885
- Author
- [email protected]
- Date
- 2019-09-15 10:17:02 -0700 (Sun, 15 Sep 2019)
Log Message
Leak of NSMapTable in -[JSVirtualMachine addManagedReference:withOwner:]
<https://webkit.org/b/201803>
Reviewed by Dan Bernstein.
* API/JSVirtualMachine.mm:
(-[JSVirtualMachine addManagedReference:withOwner:]): Use
RetainPtr<> to fix the leak.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (249884 => 249885)
--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2019-09-15 14:14:59 UTC (rev 249884)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2019-09-15 17:17:02 UTC (rev 249885)
@@ -40,6 +40,7 @@
#import <mutex>
#import <wtf/BlockPtr.h>
#import <wtf/Lock.h>
+#import <wtf/RetainPtr.h>
static NSMapTable *globalWrapperCache = 0;
@@ -180,17 +181,17 @@
[self addExternalRememberedObject:owner];
auto externalDataMutexLocker = holdLock(m_externalDataMutex);
- NSMapTable *ownedObjects = [m_externalObjectGraph objectForKey:owner];
+ RetainPtr<NSMapTable> ownedObjects = [m_externalObjectGraph objectForKey:owner];
if (!ownedObjects) {
NSPointerFunctionsOptions weakIDOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
NSPointerFunctionsOptions integerOptions = NSPointerFunctionsOpaqueMemory | NSPointerFunctionsIntegerPersonality;
- ownedObjects = [[NSMapTable alloc] initWithKeyOptions:weakIDOptions valueOptions:integerOptions capacity:1];
+ ownedObjects = adoptNS([[NSMapTable alloc] initWithKeyOptions:weakIDOptions valueOptions:integerOptions capacity:1]);
- [m_externalObjectGraph setObject:ownedObjects forKey:owner];
+ [m_externalObjectGraph setObject:ownedObjects.get() forKey:owner];
}
- size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects, (__bridge void*)object));
- NSMapInsert(ownedObjects, (__bridge void*)object, reinterpret_cast<void*>(count + 1));
+ size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects.get(), (__bridge void*)object));
+ NSMapInsert(ownedObjects.get(), (__bridge void*)object, reinterpret_cast<void*>(count + 1));
}
- (void)removeManagedReference:(id)object withOwner:(id)owner
Modified: trunk/Source/_javascript_Core/ChangeLog (249884 => 249885)
--- trunk/Source/_javascript_Core/ChangeLog 2019-09-15 14:14:59 UTC (rev 249884)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-09-15 17:17:02 UTC (rev 249885)
@@ -1,3 +1,14 @@
+2019-09-15 David Kilzer <[email protected]>
+
+ Leak of NSMapTable in -[JSVirtualMachine addManagedReference:withOwner:]
+ <https://webkit.org/b/201803>
+
+ Reviewed by Dan Bernstein.
+
+ * API/JSVirtualMachine.mm:
+ (-[JSVirtualMachine addManagedReference:withOwner:]): Use
+ RetainPtr<> to fix the leak.
+
2019-09-14 Yusuke Suzuki <[email protected]>
Retire x86 32bit JIT support
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes