From 0ed00210a137abe34c706bdb1058a7fe0bcb3dfe Mon Sep 17 00:00:00 2001 From: Wei Jiangang Date: Thu, 28 Mar 2024 12:13:57 +0800 Subject: [PATCH] Fix crash for nullptr in EstablishAuthChannel Signed-off-by: Wei Jiangang --- .../implementation/src/authentication/dm_auth_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 4b0fbd91..2874bec6 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -426,7 +426,9 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) LOGE("OpenAuthSession failed, stop the authentication"); authResponseContext_ = std::make_shared(); authResponseContext_->state = AuthState::AUTH_REQUEST_NEGOTIATE; - authRequestContext_->reason = ERR_DM_AUTH_OPEN_SESSION_FAILED; + if (authRequestContext_ != nullptr) { + authRequestContext_->reason = ERR_DM_AUTH_OPEN_SESSION_FAILED; + } if (authRequestState_ != nullptr) { authRequestState_->TransitionTo(std::make_shared()); } @@ -940,4 +942,4 @@ bool DmAuthManager::IsIdenticalAccount() return true; } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- 2.33.0