From 71c4bfdc3c70503ba73a0a9f7eda7ea1d95982cc Mon Sep 17 00:00:00 2001 From: wangfenging Date: Fri, 25 Jul 2025 17:26:39 +0800 Subject: [PATCH] Fix:memory leak Signed-off-by: wangfenging --- modules/sandbox/normal/sandbox_core.cpp | 2 -- modules/sandbox/normal/sandbox_shared_mount.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/sandbox/normal/sandbox_core.cpp b/modules/sandbox/normal/sandbox_core.cpp index 0959eafb..adda2da3 100644 --- a/modules/sandbox/normal/sandbox_core.cpp +++ b/modules/sandbox/normal/sandbox_core.cpp @@ -1056,8 +1056,6 @@ int32_t SandboxCore::ChangeCurrentDir(std::string &sandboxPackagePath, const std return ret; } - - static const DecDenyPathTemplate DEC_DENY_PATH_MAP[] = { {"ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY", "/storage/Users/currentUser/Download"}, {"ohos.permission.READ_WRITE_DESKTOP_DIRECTORY", "/storage/Users/currentUser/Desktop"}, diff --git a/modules/sandbox/normal/sandbox_shared_mount.cpp b/modules/sandbox/normal/sandbox_shared_mount.cpp index 63a02377..fae454c2 100644 --- a/modules/sandbox/normal/sandbox_shared_mount.cpp +++ b/modules/sandbox/normal/sandbox_shared_mount.cpp @@ -489,9 +489,15 @@ static int ParseDataGroupList(AppSpawnMgr *content, const AppSpawningCtx *proper { int ret = 0; cJSON *dataGroupList = GetJsonObjFromExtInfo(property, DATA_GROUP_SOCKET_TYPE); - APPSPAWN_CHECK(dataGroupList != nullptr, return APPSPAWN_ARG_INVALID, "dataGroupList is empty"); - APPSPAWN_CHECK(cJSON_IsArray(dataGroupList), cJSON_Delete(dataGroupList); - return APPSPAWN_ARG_INVALID, "dataGroupList is not Array"); + if (dataGroupList == nullptr) { + APPSPAWN_LOGE("dataGroupList is empty"); + return APPSPAWN_ARG_INVALID; + } + + if (!cJSON_IsArray(dataGroupList)) { + cJSON_Delete(dataGroupList); + return APPSPAWN_ARG_INVALID; + } // Iterate through the array (assuming groups is an array) cJSON *item = nullptr; -- Gitee