From 5050ca75239d217f4549e51b1717ebe5117dd7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E6=9D=B0?= Date: Mon, 6 Jan 2025 15:57:51 +0800 Subject: [PATCH] Issue:#IBFYPI Description: null pointer protected Sig: SIG_ApplicaitonFramework Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: renjie84 renjie84@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 任杰 --- services/bundlemgr_lite/src/bundle_manager_service.cpp | 7 +++++++ utils/bundle_lite/utils_list.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/services/bundlemgr_lite/src/bundle_manager_service.cpp b/services/bundlemgr_lite/src/bundle_manager_service.cpp index 12c817c..2d27fdf 100644 --- a/services/bundlemgr_lite/src/bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/bundle_manager_service.cpp @@ -50,6 +50,9 @@ namespace OHOS { ManagerService::ManagerService() { installer_ = new (std::nothrow) BundleInstaller(INSTALL_PATH, DATA_PATH); + if (installer_ == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS BundleInstaller is nullptr"); + } bundleMap_ = BundleMap::GetInstance(); } @@ -183,6 +186,10 @@ void ManagerService::ServiceMsgProcess(Request* request) if (installer_ == nullptr) { installer_ = new (std::nothrow) BundleInstaller(INSTALL_PATH, DATA_PATH); + if (installer_ == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS BundleInstaller is nullptr"); + return; + } } switch (request->msgId) { diff --git a/utils/bundle_lite/utils_list.h b/utils/bundle_lite/utils_list.h index ae5a959..a32577f 100644 --- a/utils/bundle_lite/utils_list.h +++ b/utils/bundle_lite/utils_list.h @@ -35,6 +35,9 @@ public: List() : count_(0) { head_ = new (std::nothrow) Node(); + if (head_ == nullptr) { + return; + } head_->next_ = head_; head_->prev_ = head_; } @@ -94,6 +97,9 @@ public: void PushBack(T value) { auto node = new (std::nothrow) Node(value); + if (node == nullptr) { + return; + } node->next_ = head_; node->prev_ = head_->prev_; -- Gitee