Fix potential crash in OpenInputStreamWrapper::Open (fixes issue #2808)

This commit is contained in:
Marshall Greenblatt 2020-01-15 16:46:18 +01:00
parent d02d252690
commit c90b65a72c
1 changed files with 5 additions and 4 deletions

View File

@ -90,10 +90,11 @@ class OpenInputStreamWrapper
void Open(const RequestId& request_id,
const network::ResourceRequest& request) {
if (!delegate_->OpenInputStream(
request_id, request,
base::BindOnce(&OpenInputStreamWrapper::OnCallback,
base::WrapRefCounted(this)))) {
// |delegate_| may be null if we were canceled.
if (delegate_ && !delegate_->OpenInputStream(
request_id, request,
base::BindOnce(&OpenInputStreamWrapper::OnCallback,
base::WrapRefCounted(this)))) {
OnCallback(nullptr);
}
}