已合并
fix null pointer dereference #2232
fix null pointer dereference #2232
已合并
rainlost创建于 8月3日
共 4 个文件变更+15-1
@@ -444,6 +444,10 @@ void MigrateManager::HandleCurBundleEndWork(std::string bundleName, const Backup
444 scenario != BackupType::INCREMENTAL_RESTORE) {444 scenario != BackupType::INCREMENTAL_RESTORE) {
445 return;445 return;
446 }446 }
447+ if (servicePtr_ == nullptr || servicePtr_->session_ == nullptr) {
448+ HILOGE("servicePtr_ or session_ is null");
449+ return;
450+ }
447 if (servicePtr_->session_->OnBundleFileReady(bundleName)) {451 if (servicePtr_->session_->OnBundleFileReady(bundleName)) {
448 std::lock_guard<std::mutex> lock(bundleEndLock_);452 std::lock_guard<std::mutex> lock(bundleEndLock_);
449 servicePtr_->session_->StopFwkTimer(bundleName);453 servicePtr_->session_->StopFwkTimer(bundleName);
@@ -462,6 +462,10 @@ ErrCode Service::AppendBundlesSessionWithDetail(const std::vector<BundleName> &b
462 BizScene &scene,462 BizScene &scene,
463 UniqueFd fd)463 UniqueFd fd)
464{464{
465+ if (session_ == nullptr) {
466+ HILOGE("session_ is nullptr");
467+ return BError(BError::Codes::SA_INVAL_ARG);
468+ }
465 try {469 try {
466 CounterHelper counterHelper(session_, __PRETTY_FUNCTION__);470 CounterHelper counterHelper(session_, __PRETTY_FUNCTION__);
467 std::vector<std::string> bundleNamesOnly;471 std::vector<std::string> bundleNamesOnly;
@@ -42,6 +42,10 @@ static bool SpecialDefaultVersion(const string &versionName)
42ErrCode Service::SetSessPropertiesRestore(const std::vector<std::string> &restoreBundleNames,42ErrCode Service::SetSessPropertiesRestore(const std::vector<std::string> &restoreBundleNames,
43 vector<BJsonEntityCaps::BundleInfo> &restoreBundleInfos)43 vector<BJsonEntityCaps::BundleInfo> &restoreBundleInfos)
44{44{
45+ if (session_ == nullptr) {
46+ HILOGE("session_ is nullptr");
47+ return BError(BError::Codes::SA_INVAL_ARG);
48+ }
45 session_->SetOldBackupVersion(oldBackupVersion_);49 session_->SetOldBackupVersion(oldBackupVersion_);
46 std::vector<std::string> strategies = {50 std::vector<std::string> strategies = {
47 "RestoreBasePropertyStrategy",51 "RestoreBasePropertyStrategy",
@@ -451,7 +451,9 @@ tuple<ErrCode, int64_t, int64_t> DefaultAppScanner::ScanDir(const string &backup
451 continue;451 continue;
452 }452 }
453 if (IsEmptyDirectory(currentPath)) {453 if (IsEmptyDirectory(currentPath)) {
454- ctx.resultManager->AddSmallFile(StringUtils::PathAddDelimiter(currentPath), 0);454+ if (ctx.resultManager != nullptr) {
455+ ctx.resultManager->AddSmallFile(StringUtils::PathAddDelimiter(currentPath), 0);
456+ }
455 continue;457 continue;
456 }458 }
457 unique_ptr<DIR, function<void(DIR *)>> dir = {opendir(currentPath.c_str()), closedir};459 unique_ptr<DIR, function<void(DIR *)>> dir = {opendir(currentPath.c_str()), closedir};