From ab6fde7a74ae90446a1ae88da82fee572a8a0466 Mon Sep 17 00:00:00 2001
From: Li Jinlin <lijinlin3@huawei.com>
Date: Tue, 29 Mar 2022 11:08:46 +0800
Subject: [PATCH 5/6] hfsplus_cache_from_extent: fix memleak

Need to release node when an error occurs

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
---
 libparted/fs/r/hfs/reloc_plus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libparted/fs/r/hfs/reloc_plus.c b/libparted/fs/r/hfs/reloc_plus.c
index f065406..44e3490 100644
--- a/libparted/fs/r/hfs/reloc_plus.c
+++ b/libparted/fs/r/hfs/reloc_plus.c
@@ -670,8 +670,10 @@ hfsplus_cache_from_extent(HfsCPrivateCache* cache, PedFileSystem* fs,
 					_("The extents overflow file should not"
 					" contain its own extents!  You should "
 					"check the file system."))
-						!= PED_EXCEPTION_IGNORE)
+						!= PED_EXCEPTION_IGNORE) {
+					free(node);
 					return 0;
+				}
 				where = CR_BTREE_EXT_EXT;
 				break;
 			    case PED_CPU_TO_BE32 (HFS_CATALOG_ID) :
-- 
2.27.0

