Skip to content

Commit

Permalink
Crash under DocumentThreadableLoader::dataReceived() dereferencing an…
Browse files Browse the repository at this point in the history
… unset std::optional

https://bugs.webkit.org/show_bug.cgi?id=288305
rdar://145354732

Reviewed by Charlie Wolfe.

Stop passing the resource load identifier to DocumentThreadableLoader::didReceiveData()
since it doesn't use it. We don't always have an identifier and it was causing crashes
trying to dereferencing an unset std::optional and for no good reason since the identifier
wasn't needed anyway.

* Source/WebCore/loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::dataReceived):
(WebCore::DocumentThreadableLoader::didReceiveData):
(WebCore::DocumentThreadableLoader::loadRequest):
* Source/WebCore/loader/DocumentThreadableLoader.h:

Canonical link: https://commits.webkit.org/290905@main
  • Loading branch information
cdumez committed Feb 23, 2025
1 parent 56d6545 commit 4a3cd84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Source/WebCore/loader/DocumentThreadableLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ void DocumentThreadableLoader::didReceiveResponse(ResourceLoaderIdentifier ident
void DocumentThreadableLoader::dataReceived(CachedResource& resource, const SharedBuffer& buffer)
{
ASSERT_UNUSED(resource, &resource == m_resource);
didReceiveData(*m_resource->resourceLoaderIdentifier(), buffer);
didReceiveData(buffer);
}

void DocumentThreadableLoader::didReceiveData(ResourceLoaderIdentifier, const SharedBuffer& buffer)
void DocumentThreadableLoader::didReceiveData(const SharedBuffer& buffer)
{
ASSERT(m_client);

Expand Down Expand Up @@ -686,7 +686,7 @@ void DocumentThreadableLoader::loadRequest(ResourceRequest&& request, SecurityCh
didReceiveResponse(identifier, response);

if (data)
didReceiveData(identifier, *data);
didReceiveData(*data);

const auto* timing = response.deprecatedNetworkLoadMetricsOrNull();
auto resourceTiming = ResourceTiming::fromSynchronousLoad(requestURL, m_options.initiatorType, loadTiming, timing ? *timing : NetworkLoadMetrics::emptyMetrics(), response, securityOrigin());
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/DocumentThreadableLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CachedRawResource;
void notifyFinished(CachedResource&, const NetworkLoadMetrics&, LoadWillContinueInAnotherProcess) override;

void didReceiveResponse(ResourceLoaderIdentifier, const ResourceResponse&);
void didReceiveData(ResourceLoaderIdentifier, const SharedBuffer&);
void didReceiveData(const SharedBuffer&);
void didFinishLoading(std::optional<ResourceLoaderIdentifier>, const NetworkLoadMetrics&);
void didFail(std::optional<ResourceLoaderIdentifier>, const ResourceError&);
void makeCrossOriginAccessRequest(ResourceRequest&&);
Expand Down

0 comments on commit 4a3cd84

Please # to comment.