RESOLVED FIXED 118533
WebResourceCacheManager::cfURLCacheHostNamesWithCallback leaks an array (pointed out by the clang static analyzer)
https://bugs.webkit.org/show_bug.cgi?id=118533
Summary WebResourceCacheManager::cfURLCacheHostNamesWithCallback leaks an array (poin...
Jessie Berlin
Reported 2013-07-10 09:56:57 PDT
#if ENABLE(CACHE_PARTITIONING) void WebResourceCacheManager::cfURLCacheHostNamesWithCallback(CacheCallback callback) { WKCFURLCacheCopyAllPartitionNames(^(CFArrayRef partitionNames) { CFMutableArrayRef hostNames = CFArrayCreateMutableCopy(0, 0, WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFSTR(""))); CFArrayAppendArray(hostNames, partitionNames, CFRangeMake(0, CFArrayGetCount(partitionNames))); CFRelease(partitionNames); callback(adoptCF(hostNames)); }); } #endif The array returned by the call to WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFSTR("”)) is getting leaked.
Attachments
Patch (1.86 KB, patch)
2013-07-10 10:03 PDT, Jessie Berlin
no flags
Jessie Berlin
Comment 1 2013-07-10 10:03:25 PDT
Anders Carlsson
Comment 2 2013-07-10 13:02:55 PDT
Comment on attachment 206395 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=206395&action=review > Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:68 > + CFMutableArrayRef hostNames = CFArrayCreateMutableCopy(0, 0, hostNamesInPersistentStore.get()); I think you can use a RetainPtr here (with adoptCF). > Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:71 > callback(adoptCF(hostNames)); and then just call std::move(hostNames) here.
Jessie Berlin
Comment 3 2013-07-11 09:21:51 PDT
(In reply to comment #2) > (From update of attachment 206395 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=206395&action=review > > > Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:68 > > + CFMutableArrayRef hostNames = CFArrayCreateMutableCopy(0, 0, hostNamesInPersistentStore.get()); > > I think you can use a RetainPtr here (with adoptCF). Done. > > > Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:71 > > callback(adoptCF(hostNames)); > > and then just call std::move(hostNames) here. Done. Thanks for the review!
Jessie Berlin
Comment 4 2013-07-11 15:28:34 PDT
Note You need to log in before you can comment on or make changes to this bug.