Skip to content
Permalink
Browse files
<http://webkit.org/b/66113> [CFNetwork] willCacheResponse() leaks CFC…
…achedURLResponseRef if delegate changes CacheStoragePolicy

Reviewed by Joseph Pecoraro.

This first appeared in ToT WebKit r23462 (Windows merge).

* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::willCacheResponse): Only retain cachedResponse if we
are returning the same object passed into the method, otherwise
we end up double-retaining the new object created.


Canonical link: https://commits.webkit.org/81962@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92897 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ddkilzer committed Aug 12, 2011
1 parent 872a06e commit 23b69cb7d65c00dadb31fd246d8c2f97e73ebc96
Showing with 16 additions and 2 deletions.
  1. +13 −0 Source/WebCore/ChangeLog
  2. +3 −2 Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
@@ -1,3 +1,16 @@
2011-08-11 David Kilzer <ddkilzer@apple.com>

<http://webkit.org/b/66113> [CFNetwork] willCacheResponse() leaks CFCachedURLResponseRef if delegate changes CacheStoragePolicy

Reviewed by Joseph Pecoraro.

This first appeared in ToT WebKit r23462 (Windows merge).

* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::willCacheResponse): Only retain cachedResponse if we
are returning the same object passed into the method, otherwise
we end up double-retaining the new object created.

2011-08-05 Nat Duca <nduca@chromium.org>

[chromium] Make WebViewImpl point at CCLayerTreeHost and related separation
@@ -328,13 +328,14 @@ static CFCachedURLResponseRef willCacheResponse(CFURLConnectionRef, CFCachedURLR
if (handle->client())
handle->client()->willCacheResponse(handle, policy);

if (static_cast<CFURLCacheStoragePolicy>(policy) != CFCachedURLResponseGetStoragePolicy(cachedResponse))
if (static_cast<CFURLCacheStoragePolicy>(policy) != CFCachedURLResponseGetStoragePolicy(cachedResponse)) {
cachedResponse = CFCachedURLResponseCreateWithUserInfo(kCFAllocatorDefault,
CFCachedURLResponseGetWrappedResponse(cachedResponse),
CFCachedURLResponseGetReceiverData(cachedResponse),
CFCachedURLResponseGetUserInfo(cachedResponse),
static_cast<CFURLCacheStoragePolicy>(policy));
CFRetain(cachedResponse);
} else
CFRetain(cachedResponse);

return cachedResponse;
}

0 comments on commit 23b69cb

Please sign in to comment.