Skip to content

Commit

Permalink
Fix crash if a pending request is continued after deletion (see issue c…
Browse files Browse the repository at this point in the history
…hromiumembedded#2622).

This is a speculative fix for a crash where the pending ResourceRequest appears
to be invalid after the request is continued from SetInitialized.
  • Loading branch information
magreenblatt committed Jun 19, 2019
1 parent ba08c21 commit b03a419
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libcef/browser/net_service/proxy_url_loader_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,9 @@ void InterceptedRequest::ContinueToResponseStarted(int error_code) {
}

void InterceptedRequest::OnDestroy() {
// We don't want any callbacks after this point.
weak_factory_.InvalidateWeakPtrs();

factory_->request_handler_->OnRequestComplete(id_, request_, status_);

// Destroys |this|.
Expand Down
14 changes: 13 additions & 1 deletion libcef/browser/net_service/resource_request_handler_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,19 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {

RequestState* state = GetState(id);
if (!state) {
// The request may have been canceled during destruction.
// The request may have been aborted during initialization or canceled
// during destruction. This method will always be called before a request
// is deleted, so if the request is currently pending also remove it from
// the list.
if (!pending_requests_.empty()) {
PendingRequests::iterator it = pending_requests_.begin();
for (; it != pending_requests_.end(); ++it) {
if ((*it)->id_ == id) {
pending_requests_.erase(it);
break;
}
}
}
return;
}

Expand Down

0 comments on commit b03a419

Please sign in to comment.