cleanup_config: Free all member before freeing structure 20/318320/1 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20250116.162908
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 13 Jan 2025 05:19:09 +0000 (14:19 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Wed, 15 Jan 2025 10:28:44 +0000 (19:28 +0900)
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 <unsung.lee@samsung.com>
src/storage/cleanup_config.c

index 115c680346edcefe00d0292349dc737caaaf3edd..bf84f7628e019916b95717647579e59b227533df 100644 (file)
@@ -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;
 }