-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Correct nullptr dereference in DocumentLoader::responseReceived #47079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct nullptr dereference in DocumentLoader::responseReceived #47079
Conversation
EWS run on previous version of this PR (hash 5217f45) |
@@ -1000,14 +1001,17 @@ void DocumentLoader::responseReceived(ResourceResponse&& response, CompletionHan | |||
if (m_substituteData.isValid() || !platformStrategies()->loaderStrategy()->havePerformedSecurityChecks(response)) { | |||
auto url = response.url(); | |||
RefPtr frame = m_frame.get(); | |||
ContentSecurityPolicy contentSecurityPolicy(URL { url }, this, frame->document()); | |||
ReportingClient* reportingClient = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a step in the wrong direction. Why not just use a RefPtr<Document>?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t want to take ownership of the Document, so perhaps a WeakPtr. After looking at this yesterday, I think this argument to CSP was hacked in a bit poorly, and would need a larger patch to get this right.
I took the approach of matching the logic in the other overload of this method, and intend to follow up with a patch that addresses the ugly bare pointer used for this argument in current code.
Failed mac-AS-debug-wk2 checks. Please resolve failures and re-apply Rejecting #47079 from merge queue. |
Safe-Merge-Queue: Build #61260. |
@@ -1035,12 +1039,15 @@ void DocumentLoader::responseReceived(ResourceResponse&& response, CompletionHan | |||
m_response = WTFMove(response); | |||
|
|||
if (m_identifierForLoadWithoutResourceLoader) { | |||
RefPtr protectedFrameLoader { frameLoader() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not call local variable protectedXXX
anymore. This is pre-safer CPP style. This should be:
RefPtr frameLoader = this->frameLoader();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will fix.
@@ -1053,18 +1060,24 @@ void DocumentLoader::responseReceived(ResourceResponse&& response, CompletionHan | |||
return; | |||
} | |||
|
|||
RefPtr protectedFrame { m_frame.get() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? Why can't we reuse the frame
local variable in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's possible. It's hard to read diffs sometimes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're moving it, we should name it frame
, not protectedFrame
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
5217f45
to
8aa6908
Compare
EWS run on current version of this PR (hash 8aa6908) |
Safe-Merge-Queue: Build #61307. |
https://bugs.webkit.org/show_bug.cgi?id=294863 <rdar://problem/153030488> Reviewed by Charlie Wolfe. Telemetry from recent betas indicate nullptr crashes in `DocumentLoader::responseReceived`. This patch corrects this error. * Source/WebCore/loader/DocumentLoader.cpp: (WebCore::DocumentLoader::responseReceived): Correct nullptr frame checks. Also a Drive-by-fix to add missing call to the completion handler. (WebCore::DocumentLoader::responseReceived): Correct nullptr checks. Canonical link: https://commits.webkit.org/296582@main
8aa6908
to
97054b3
Compare
Committed 296582@main (97054b3): https://commits.webkit.org/296582@main Reviewed commits have been landed. Closing PR #47079 and removing active labels. |
97054b3
8aa6908