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

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