Commit d576715b authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Manually close FrameHost receiver upon Portal related bad messages

|mojo::ReportBadMessage| does not automatically close the relevant
receiver (|frame_host_associated_receiver_|). We return immediately
after the |ReportBadMessage|, so the callbacks are not run. Since the
pipe is not closed, this DCHECKS.

Bug: None
Change-Id: I521fe8c29679a92c9d5689e78758e4adde814b00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929911
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718690}
parent 0e41504a
......@@ -4459,10 +4459,21 @@ void RenderFrameHostImpl::CreatePortal(
if (frame_tree_node()->parent()) {
mojo::ReportBadMessage(
"RFHI::CreatePortal called in a nested browsing context");
frame_host_associated_receiver_.reset();
return;
}
Portal* portal =
Portal::Create(this, std::move(pending_receiver), std::move(client));
if (!portal) {
// |portal| is null when |Portal::Create| reports a bad message, so we need
// to close the receiver.
// TODO(1027302): Remove these manual calls to reset once we have a cleaner
// way of reporting a bad message for an AssociatedReceiver.
frame_host_associated_receiver_.reset();
return;
}
RenderFrameProxyHost* proxy_host = portal->CreateProxyAndAttachPortal();
std::move(callback).Run(proxy_host->GetRoutingID(), portal->portal_token(),
portal->GetDevToolsFrameToken());
......@@ -4474,10 +4485,12 @@ void RenderFrameHostImpl::AdoptPortal(
Portal* portal = Portal::FromToken(portal_token);
if (!portal) {
mojo::ReportBadMessage("Unknown portal_token when adopting portal.");
frame_host_associated_receiver_.reset();
return;
}
if (portal->owner_render_frame_host() != this) {
mojo::ReportBadMessage("AdoptPortal called from wrong frame.");
frame_host_associated_receiver_.reset();
return;
}
RenderFrameProxyHost* proxy_host = portal->CreateProxyAndAttachPortal();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment