From 0a81e8953a3c7a0a412f368ee4030a691ab0c38a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 8 Aug 2019 13:44:16 +0900 Subject: [PATCH] Fix resource leak Change-Id: I20892cf837bde1328e36b3dc3168830ce3fb9589 Signed-off-by: Hwankyu Jhun --- src/aul_comp_context.c | 1 + src/aul_comp_info.c | 4 +++- src/aul_comp_info_internal.c | 2 +- src/launch.c | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aul_comp_context.c b/src/aul_comp_context.c index 001519c..ed86ac0 100644 --- a/src/aul_comp_context.c +++ b/src/aul_comp_context.c @@ -371,6 +371,7 @@ API int aul_comp_context_usr_create(const char *comp_id, uid_t uid, b = bundle_decode(pkt->data, pkt->len); if (!b) { _E("Failed to decode bundle"); + free(pkt); return AUL_R_ENOMEM; } } diff --git a/src/aul_comp_info.c b/src/aul_comp_info.c index d71e465..d956c4e 100644 --- a/src/aul_comp_info.c +++ b/src/aul_comp_info.c @@ -550,17 +550,18 @@ static int __comp_info_add_localized_info(bundle *b, size); if (!decoded_b) { _E("Failed to decode bundle"); + __comp_info_remove_localized_info(list); return -1; } localized_info = __create_comp_localized_info(decoded_b); + bundle_free(decoded_b); if (!localized_info) { __comp_info_remove_localized_info(list); return -1; } list = g_list_append(list, localized_info); - bundle_free(decoded_b); } info->value[AUL_COMP_INFO_LOCALIZED_INFO] = (char *)list; @@ -905,6 +906,7 @@ API int aul_comp_info_usr_create(const char *comp_id, uid_t uid, b = bundle_decode(pkt->data, pkt->len); if (!b) { _E("Failed to decode bundle"); + free(pkt); return AUL_R_ENOMEM; } } diff --git a/src/aul_comp_info_internal.c b/src/aul_comp_info_internal.c index d0b4da8..76acd7f 100644 --- a/src/aul_comp_info_internal.c +++ b/src/aul_comp_info_internal.c @@ -193,7 +193,7 @@ static struct aul_compinfo_s *__clone_compinfo(struct aul_compinfo_s *info) compinfo->value[idx] = strdup(info->value[idx]); if (!compinfo->value[idx]) { _E("Out of memory"); - __destroy_compinfo(info); + __destroy_compinfo(compinfo); return NULL; } } diff --git a/src/launch.c b/src/launch.c index 0dca6b4..98fe395 100755 --- a/src/launch.c +++ b/src/launch.c @@ -969,6 +969,7 @@ static int __send_request(int cmd, uid_t uid, const char *appid, ret = bundle_add(b, AUL_K_INSTANCE_ID, instance_id); if (ret != BUNDLE_ERROR_NONE) { _E("Failed to add instance ID"); + bundle_free(b); if (ret == BUNDLE_ERROR_OUT_OF_MEMORY) return AUL_R_ENOMEM; else if (ret == BUNDLE_ERROR_INVALID_PARAMETER) -- 2.7.4