Blame SOURCES/e2fsprogs-1.45.6-debugfs-fix-memory-leak-problem-in-read_list.patch

a77133
From 9221fb77a7187957ed84e45bf6ad6f5e37755e5c Mon Sep 17 00:00:00 2001
a77133
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Date: Sat, 20 Feb 2021 16:41:29 +0800
a77133
Subject: [PATCH 22/46] debugfs: fix memory leak problem in read_list()
a77133
Content-Type: text/plain
a77133
a77133
In read_list func, if strtoull() fails in while loop,
a77133
we will return the error code directly. Then, memory of
a77133
variable lst will be leaked without setting to *list.
a77133
a77133
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Signed-off-by: linfeilong <linfeilong@huawei.com>
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 debugfs/util.c | 12 ++++++++----
a77133
 1 file changed, 8 insertions(+), 4 deletions(-)
a77133
a77133
diff --git a/debugfs/util.c b/debugfs/util.c
a77133
index bbb20ff6..37620295 100644
a77133
--- a/debugfs/util.c
a77133
+++ b/debugfs/util.c
a77133
@@ -530,12 +530,16 @@ errcode_t read_list(char *str, blk64_t **list, size_t *len)
a77133
 
a77133
 		errno = 0;
a77133
 		y = x = strtoull(tok, &e, 0);
a77133
-		if (errno)
a77133
-			return errno;
a77133
+		if (errno) {
a77133
+			retval = errno;
a77133
+			break;
a77133
+		}
a77133
 		if (*e == '-') {
a77133
 			y = strtoull(e + 1, NULL, 0);
a77133
-			if (errno)
a77133
-				return errno;
a77133
+			if (errno) {
a77133
+				retval = errno;
a77133
+				break;
a77133
+			}
a77133
 		} else if (*e != 0) {
a77133
 			retval = EINVAL;
a77133
 			break;
a77133
-- 
a77133
2.35.1
a77133