Title: [150613] trunk/Source/WebCore
Revision
150613
Author
[email protected]
Date
2013-05-23 14:17:43 -0700 (Thu, 23 May 2013)

Log Message

We need to clear main resource when detaching DocumentLoader from the frame.
https://bugs.webkit.org/show_bug.cgi?id=116680

Normally, when we detach the documentLoader in DocumentLoader::detachFromFrame, main resource is also cleared
in stopLoading().  There is possibility that main resource not being cleared, and this could cause crash later
since docLoader could still receive resource callbacks.  To avoid that, we can remove docLoader from main resource's
client set in detachFromFrame.

Patch by Yongjun Zhang <[email protected]> on 2013-05-23
Reviewed by Brady Eidson.

No new tests, this doesn't happen on OS X.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::clearMainResource):
* loader/cache/CachedResource.h: make hasClient accessible publicly.
(WebCore::CachedResource::hasClient):
(CachedResource):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150612 => 150613)


--- trunk/Source/WebCore/ChangeLog	2013-05-23 20:59:48 UTC (rev 150612)
+++ trunk/Source/WebCore/ChangeLog	2013-05-23 21:17:43 UTC (rev 150613)
@@ -1,3 +1,24 @@
+2013-05-23  Yongjun Zhang  <[email protected]>
+
+        We need to clear main resource when detaching DocumentLoader from the frame.
+        https://bugs.webkit.org/show_bug.cgi?id=116680
+
+        Normally, when we detach the documentLoader in DocumentLoader::detachFromFrame, main resource is also cleared
+        in stopLoading().  There is possibility that main resource not being cleared, and this could cause crash later
+        since docLoader could still receive resource callbacks.  To avoid that, we can remove docLoader from main resource's
+        client set in detachFromFrame.
+
+        Reviewed by Brady Eidson.
+
+        No new tests, this doesn't happen on OS X.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::detachFromFrame):
+        (WebCore::DocumentLoader::clearMainResource):
+        * loader/cache/CachedResource.h: make hasClient accessible publicly.
+        (WebCore::CachedResource::hasClient):
+        (CachedResource):
+
 2013-05-23  Mihai Maerean  <[email protected]>
 
         assertion failed: !node || node->isElementNode() in WebCore::RenderBlock::clone

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (150612 => 150613)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-05-23 20:59:48 UTC (rev 150612)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-05-23 21:17:43 UTC (rev 150613)
@@ -896,6 +896,8 @@
     // It never makes sense to have a document loader that is detached from its
     // frame have any loads active, so go ahead and kill all the loads.
     stopLoading();
+    if (m_mainResource && m_mainResource->hasClient(this))
+        m_mainResource->removeClient(this);
 
     m_applicationCacheHost->setDOMApplicationCache(0);
     InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this);
@@ -1413,10 +1415,10 @@
 
 void DocumentLoader::clearMainResource()
 {
-    if (m_mainResource) {
+    if (m_mainResource && m_mainResource->hasClient(this))
         m_mainResource->removeClient(this);
-        m_mainResource = 0;
-    }
+
+    m_mainResource = 0;
 }
 
 void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loader)

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (150612 => 150613)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2013-05-23 20:59:48 UTC (rev 150612)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2013-05-23 21:17:43 UTC (rev 150613)
@@ -122,6 +122,7 @@
     void addClient(CachedResourceClient*);
     void removeClient(CachedResourceClient*);
     bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty(); }
+    bool hasClient(CachedResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client); }
     bool deleteIfPossible();
 
     enum PreloadResult {
@@ -276,8 +277,6 @@
     };
     HashMap<CachedResourceClient*, OwnPtr<CachedResourceCallback> > m_clientsAwaitingCallback;
 
-    bool hasClient(CachedResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client); }
-
     ResourceRequest m_resourceRequest;
     String m_accept;
     RefPtr<SubresourceLoader> m_loader;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to