From 2571d285a092dc8b6b7159ba906682716e033631 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 26 Sep 2022 22:21:38 +0800 Subject: [PATCH] fix problem Signed-off-by: shilei Change-Id: Ief8d1a1bd6918d6b414fe5241a2fa88aa1eac335 --- frameworks/bundle_lite/src/bundle_manager.cpp | 9 +++++++-- .../bundlemgr_lite/src/gt_bundle_manager_service.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index da16a97..a244cb9 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 2d35f6f..4b00319 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) { -- Gitee