Blame SOURCES/e2fsprogs-1.45.6-zap_sector-fix-memory-leak.patch

a77133
From 8f0e75091cfcbdfbfa0f6d0e379e153ddaa268ac Mon Sep 17 00:00:00 2001
a77133
From: wuguanghao <wuguanghao3@huawei.com>
a77133
Date: Wed, 30 Jun 2021 16:27:15 +0800
a77133
Subject: [PATCH 28/46] zap_sector: fix memory leak
a77133
Content-Type: text/plain
a77133
a77133
In zap_sector(), need free buf before return,
a77133
otherwise it will cause memory leak.
a77133
a77133
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
a77133
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Reviewed-by: Wu Bo <wubo40@huawei.com>
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 misc/mke2fs.c | 4 +++-
a77133
 1 file changed, 3 insertions(+), 1 deletion(-)
a77133
a77133
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
a77133
index 0184a3a8..389d0981 100644
a77133
--- a/misc/mke2fs.c
a77133
+++ b/misc/mke2fs.c
a77133
@@ -582,8 +582,10 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
a77133
 		else {
a77133
 			magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
a77133
 			if ((*magic == BSD_DISKMAGIC) ||
a77133
-			    (*magic == BSD_MAGICDISK))
a77133
+			    (*magic == BSD_MAGICDISK)) {
a77133
+				free(buf);
a77133
 				return;
a77133
+			}
a77133
 		}
a77133
 	}
a77133
 
a77133
-- 
a77133
2.35.1
a77133