From 9b8ccb8e7e8f1d45315b984ecdbf0ab19870b3dd Mon Sep 17 00:00:00 2001 From: tangjie02 Date: Tue, 9 Aug 2022 10:45:00 +0800 Subject: [PATCH] fix(coredump): Fix coredump problem caused by nullpointer to SPwd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复由于访问SPwd空指针引起的崩溃问题。 Signed-off-by: tangjie02 --- plugins/accounts/accounts-wrapper.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/accounts/accounts-wrapper.cpp b/plugins/accounts/accounts-wrapper.cpp index 2cbee6c..4f313f6 100644 --- a/plugins/accounts/accounts-wrapper.cpp +++ b/plugins/accounts/accounts-wrapper.cpp @@ -42,13 +42,14 @@ std::vector AccountsWrapper::get_passwds_shadows() for (auto iter = this->passwds_.begin(); iter != this->passwds_.end(); ++iter) { auto spwd = this->spwds_.find(iter->first); - if (spwd == this->spwds_.end()) + // 如果spwd不存在,可能是因为账户正在创建中,这个时候不作为返回值,避免出现处理空指针引起的崩溃问题 + if (spwd != this->spwds_.end()) { - passwds_shadows.push_back(std::make_pair(iter->second, nullptr)); + passwds_shadows.push_back(std::make_pair(iter->second, spwd->second)); } else { - passwds_shadows.push_back(std::make_pair(iter->second, spwd->second)); + KLOG_DEBUG("The shadow info isn't found."); } } -- 2.33.0