Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Unified Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp

Issue 1902683002: DocumentThreadableLoader: Add guards for sync notifyFinished() in setResource() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
index 2e82f636155df855d69dd6a1789aed0c8d70f67b..0750ff0c81d7f292c1cf4fc671cf3ec52f3e3fe6 100644
--- a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
@@ -842,6 +842,8 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Resou
newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
ASSERT(!resource());
+ WeakPtr<DocumentThreadableLoader> self(m_weakFactory.createWeakPtr());
+
if (request.requestContext() == WebURLRequest::RequestContextVideo || request.requestContext() == WebURLRequest::RequestContextAudio)
setResource(RawResource::fetchMedia(newRequest, document().fetcher()));
else if (request.requestContext() == WebURLRequest::RequestContextManifest)
@@ -849,9 +851,16 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Resou
else
setResource(RawResource::fetch(newRequest, document().fetcher()));
+ // setResource() might call notifyFinished() synchronously, and thus
+ // clear() might be called and |this| may be dead here.
+ if (!self)
+ return;
+
if (!resource()) {
ThreadableLoaderClient* client = m_client;
clear();
+ if (!client)
+ return;
tyoshino (SeeGerritForStatus) 2016/04/19 06:27:44 add comment to note that we need to call clear() f
tyoshino (SeeGerritForStatus) 2016/04/19 06:29:00 oh, basically the same as what you've put in the d
hiroshige 2016/04/19 06:40:48 Done.
tyoshino (SeeGerritForStatus) 2016/04/19 08:31:32 Thanks. LGTM
client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestURL.getString(), "Failed to start loading."));
// |this| may be dead here.
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698