diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 423a8b879930610f42d802cd48518006e4325a15..dc45221d822954e94c2803a67629bdc6841a98b1 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -7972,13 +7972,17 @@ bool BundleDataMgr::CreateAppGroupDir(const InnerBundleInfo &info, int32_t userI bool BundleDataMgr::CreateAppGroupDir(const std::string &bundleName, int32_t userId) { - std::shared_lock lock(bundleInfoMutex_); - auto bundleInfoItem = bundleInfos_.find(bundleName); - if (bundleInfoItem == bundleInfos_.end()) { - APP_LOGW("%{public}s not found", bundleName.c_str()); - return false; + InnerBundleInfo info; + { + std::shared_lock lock(bundleInfoMutex_); + auto bundleInfoItem = bundleInfos_.find(bundleName); + if (bundleInfoItem == bundleInfos_.end()) { + APP_LOGW("%{public}s not found", bundleName.c_str()); + return false; + } + info = bundleInfoItem->second; } - return CreateAppGroupDir(bundleInfoItem->second, userId); + return CreateAppGroupDir(info, userId); } ErrCode BundleDataMgr::CreateGroupDirs(const std::vector &dataGroupInfos, int32_t userId,