From b97bdc9e63872bef2164a3b97ab837ac607ccf16 Mon Sep 17 00:00:00 2001
From: gaohuatao <gaohuatao@huawei.com>
Date: Fri, 3 Dec 2021 16:36:18 +0800
Subject: [PATCH] fix mem leak

Signed-off-by: gaohuatao <gaohuatao@huawei.com>
---
 src/daemon/modules/image/oci/storage/image_store/image_store.c | 3 ++-
 .../modules/image/oci/storage/rootfs_store/rootfs_store.c      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/daemon/modules/image/oci/storage/image_store/image_store.c b/src/daemon/modules/image/oci/storage/image_store/image_store.c
index d2956114..288d7bd7 100644
--- a/src/daemon/modules/image/oci/storage/image_store/image_store.c
+++ b/src/daemon/modules/image/oci/storage/image_store/image_store.c
@@ -2980,7 +2980,8 @@ static int append_image_by_directory(const char *image_dir)
     im = storage_image_parse_file(image_path, NULL, &err);
     if (im == NULL) {
         ERROR("Failed to parse images path: %s", err);
-        return -1;
+        ret = -1;
+        goto out;
     }
 
     ret = strip_default_hostname(im);
diff --git a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
index 8e1d5a11..378d1a96 100644
--- a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
+++ b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
@@ -177,7 +177,8 @@ static int append_container_by_directory(const char *container_dir)
     c = storage_rootfs_parse_file(container_path, NULL, &err);
     if (c == NULL) {
         ERROR("Failed to parse container path: %s", err);
-        return -1;
+        ret = -1;
+        goto out;
     }
 
     if (do_append_container(c) != 0) {
-- 
2.25.1

