diff --git a/remoting/protocol/negotiating_client_authenticator.cc b/remoting/protocol/negotiating_client_authenticator.cc index 678a3be1c613e..c2bc63173140c 100644 --- a/remoting/protocol/negotiating_client_authenticator.cc +++ b/remoting/protocol/negotiating_client_authenticator.cc @@ -115,6 +115,10 @@ void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( base::OnceClosure resume_callback) { DCHECK_EQ(state(), PROCESSING_MESSAGE); DCHECK(current_method_ != AuthenticationMethod::INVALID); + // |fetch_secret_callback| (and the resume_callback chained behind it) may run + // synchronously and re-entrantly destroy |this| via + // JingleSession::Close -> SetState(FAILED) -> ... -> connection_.reset(). + auto self = weak_factory_.GetWeakPtr(); switch (current_method_) { case AuthenticationMethod::INVALID: NOTREACHED(); @@ -145,6 +149,9 @@ void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( NOTREACHED(); } + if (!self) { + return; + } ChainStateChangeAfterAcceptedWithUnderlying(*current_authenticator_); }