已开启
Resolve null pointer reference issues #2265
dongtingchi创建于 12 天前
Resolve null pointer reference issues #2265
已开启
共 4 个文件变更+15-1
| @@ -440,6 +440,10 @@ void MigrateManager::HandleCurBundleEndWork(std::string bundleName, const Backup | |||
| 440 | scenario != BackupType::INCREMENTAL_RESTORE) { | 440 | scenario != BackupType::INCREMENTAL_RESTORE) { |
| 441 | return; | 441 | return; |
| 442 | } | 442 | } |
| 443 | + if (servicePtr_ == nullptr || servicePtr_->session_ == nullptr) { | ||
| 444 | + HILOGE("servicePtr_ or session_ is null"); | ||
| 445 | + return; | ||
| 446 | + } | ||
| 443 | if (servicePtr_->session_->OnBundleFileReady(bundleName)) { | 447 | if (servicePtr_->session_->OnBundleFileReady(bundleName)) { |
| 444 | std::lock_guard<std::mutex> lock(bundleEndLock_); | 448 | std::lock_guard<std::mutex> lock(bundleEndLock_); |
| 445 | servicePtr_->session_->StopFwkTimer(bundleName); | 449 | servicePtr_->session_->StopFwkTimer(bundleName); |
| @@ -478,6 +478,10 @@ ErrCode Service::AppendBundlesSessionWithDetail(const std::vector<BundleName> &b | |||
| 478 | BizScene &scene, | 478 | BizScene &scene, |
| 479 | UniqueFd fd) | 479 | UniqueFd fd) |
| 480 | { | 480 | { |
| 481 | + if (session_ == nullptr) { | ||
| 482 | + HILOGE("session_ is nullptr"); | ||
| 483 | + return BError(BError::Codes::SA_INVAL_ARG); | ||
| 484 | + } | ||
| 481 | try { | 485 | try { |
| 482 | CounterHelper counterHelper(session_, __PRETTY_FUNCTION__); | 486 | CounterHelper counterHelper(session_, __PRETTY_FUNCTION__); |
| 483 | std::vector<std::string> bundleNamesOnly; | 487 | std::vector<std::string> bundleNamesOnly; |
| @@ -42,6 +42,10 @@ static bool SpecialDefaultVersion(const string &versionName) | |||
| 42 | ErrCode Service::SetSessPropertiesRestore(const std::vector<std::string> &restoreBundleNames, | 42 | ErrCode 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}; |