Bug 1598516 - Don't crash if NS_NewChannelInternal fails. r=mayhemer

Looks like this can sometimes fail with moz-extension URIs, so we shouldn't crash

Differential Revision: https://phabricator.services.mozilla.com/D54249

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-12-03 06:20:11 +00:00
Родитель d132c8c940
Коммит 15db260efa
2 изменённых файлов: 22 добавлений и 17 удалений

Просмотреть файл

@ -3680,12 +3680,6 @@ mozilla::ipc::IPCResult ContentChild::RecvCrossProcessRedirect(
nullptr, // aCallbacks
aArgs.newLoadFlags());
RefPtr<nsIChildChannel> childChannel = do_QueryObject(newChannel);
if (NS_FAILED(rv) || !childChannel) {
MOZ_DIAGNOSTIC_ASSERT(false, "NS_NewChannelInternal failed");
return IPC_OK();
}
// This is used to report any errors back to the parent by calling
// CrossProcessRedirectFinished.
RefPtr<HttpChannelChild> httpChild = do_QueryObject(newChannel);
@ -3693,15 +3687,27 @@ mozilla::ipc::IPCResult ContentChild::RecvCrossProcessRedirect(
if (httpChild) {
rv = httpChild->CrossProcessRedirectFinished(rv);
}
Maybe<LoadInfoArgs> loadInfoArgs;
if (newChannel && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILoadInfo> loadInfo;
MOZ_ALWAYS_SUCCEEDS(newChannel->GetLoadInfo(getter_AddRefs(loadInfo)));
Maybe<LoadInfoArgs> loadInfoArgs;
MOZ_ALWAYS_SUCCEEDS(
mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs));
}
aResolve(
Tuple<const nsresult&, const Maybe<LoadInfoArgs>&>(rv, loadInfoArgs));
});
if (NS_FAILED(rv)) {
return IPC_OK();
}
RefPtr<nsIChildChannel> childChannel = do_QueryObject(newChannel);
if (!childChannel) {
rv = NS_ERROR_UNEXPECTED;
return IPC_OK();
}
if (httpChild) {
rv = httpChild->SetChannelId(aArgs.channelId());
if (NS_FAILED(rv)) {

Просмотреть файл

@ -310,13 +310,6 @@ IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
nullptr, // aCallbacks
aArgs.newLoadFlags());
RefPtr<HttpChannelChild> httpChild = do_QueryObject(newChannel);
RefPtr<nsIChildChannel> childChannel = do_QueryObject(newChannel);
if (NS_FAILED(rv)) {
MOZ_DIAGNOSTIC_ASSERT(false, "NS_NewChannelInternal failed");
return IPC_OK();
}
// This is used to report any errors back to the parent by calling
// CrossProcessRedirectFinished.
auto scopeExit = MakeScopeExit([&]() {
@ -326,6 +319,11 @@ IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
mRedirectResolver = nullptr;
});
if (NS_FAILED(rv)) {
return IPC_OK();
}
RefPtr<HttpChannelChild> httpChild = do_QueryObject(newChannel);
if (httpChild) {
rv = httpChild->SetChannelId(aArgs.channelId());
}
@ -376,6 +374,7 @@ IPCResult DocumentChannelChild::RecvRedirectToRealChannel(
}
// connect parent.
nsCOMPtr<nsIChildChannel> childChannel = do_QueryInterface(newChannel);
if (childChannel) {
rv = childChannel->ConnectParent(
aArgs.registrarId()); // creates parent channel