Skip to content

Commit

Permalink
Check callback availability in SpdyProxyClientSocket::RunWriteCallback
Browse files Browse the repository at this point in the history
OnClose() could consume `write_callback_` so it may not be available
when RunWriteCallback() is invoked.

Bug: 1428820
Change-Id: I9a5ade62d67f5bf15e12d0915d1ad6098657ffd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4437791
Code-Coverage: Findit <[email protected]>
Reviewed-by: Adam Rice <[email protected]>
Commit-Queue: Kenichi Ishibashi <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1131689}
  • Loading branch information
bashi authored and klzgrad committed May 6, 2023
1 parent 900f316 commit 2396bbe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/net/spdy/spdy_proxy_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const {
}

void SpdyProxyClientSocket::RunWriteCallback(int result) {
CHECK(write_callback_);

base::WeakPtr<SpdyProxyClientSocket> weak_ptr = weak_factory_.GetWeakPtr();
std::move(write_callback_).Run(result);
// `write_callback_` might be consumed by OnClose().
if (write_callback_) {
std::move(write_callback_).Run(result);
}
if (!weak_ptr) {
// `this` was already destroyed while running `write_callback_`. Must
// return immediately without touching any field member.
Expand Down

0 comments on commit 2396bbe

Please sign in to comment.