From f3b7b7039c0651990d4889257e97a26cc49843af Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Mon, 13 Jan 2025 14:19:09 +0900 Subject: [PATCH] cleanup_config: Free all member before freeing structure Free all members of cleanup_config before freeing this structure. Previously, the structure is freed at error situation without freeing the member. Change-Id: Ibb9218abb4a1e3913a8cd8ace0d2306382a8bc7a Signed-off-by: Unsung Lee --- src/storage/cleanup_config.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/storage/cleanup_config.c b/src/storage/cleanup_config.c index 115c680..bf84f76 100644 --- a/src/storage/cleanup_config.c +++ b/src/storage/cleanup_config.c @@ -280,6 +280,7 @@ static GList *parsing_json_array_object_to_list(struct json_object *array, int * memset(item, '\0', item_size); if (add_config_item(json_object_get(obj), item) != 0) { + free_config_item(item); RESULT(ret, -EINVAL); goto cleanup; } @@ -288,9 +289,6 @@ static GList *parsing_json_array_object_to_list(struct json_object *array, int * RESULT(ret, 0); return list; cleanup: - if (item) - free(item); - g_list_free_full(list, free_config_item); return NULL; } -- 2.34.1