diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index da16a97f75461e328089c1d556697ea42e19aeff..a244cb9d581d565fafde90db3b79234178f22f57 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -601,9 +601,14 @@ static uint8_t ObtainBundleInfosOneByOne(BasicInfo basicInfo, int32_t len, uint8 resultOfGetBundleInfo.bundleInfo = nullptr; int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, &resultOfGetBundleInfo, Notify); if (ret != OHOS_SUCCESS) { - HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d\n", ret); + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d", ret); return ERR_APPEXECFWK_INVOKE_ERROR; } + if (resultOfGetBundleInfo.bundleInfo == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne failed: %{public}d", + resultOfGetBundleInfo.resultCode); + return resultOfGetBundleInfo.resultCode; + } OHOS::BundleInfoUtils::CopyBundleInfo(basicInfo.flags, *bundleInfos + i, *(resultOfGetBundleInfo.bundleInfo)); ClearBundleInfo(resultOfGetBundleInfo.bundleInfo); AdapterFree(resultOfGetBundleInfo.bundleInfo); @@ -660,7 +665,7 @@ static uint8_t ObtainBundleInfos(BasicInfo basicInfo, BundleInfo **bundleInfos, } *len = resultOfGetBundleInfos.length; OHOS::BundleInfoUtils::FreeBundleInfos(resultOfGetBundleInfos.bundleInfo, resultOfGetBundleInfos.length); - return resultOfGetBundleInfos.resultCode; + return res; } uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len) diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 2d35f6f829eb3a6b2458f3303bf78a8488202f1e..4b003196d73774d7d50212ecd5f09836ff31c0e8 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -1009,6 +1009,7 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) } char *fileName = reinterpret_cast(AdapterMalloc(MAX_NAME_LEN + 1)); if (fileName == nullptr) { + closedir(dir); return; } while ((ent = readdir(dir)) != nullptr) {