forked from rpms/e2fsprogs
35 lines
1.0 KiB
Diff
35 lines
1.0 KiB
Diff
From 9e298ba470a6abc7d94fe659cf65fcb0b993c0b8 Mon Sep 17 00:00:00 2001
|
|
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
|
Date: Wed, 30 Jun 2021 16:27:19 +0800
|
|
Subject: [PATCH 30/46] argv_parse: check return value of malloc in
|
|
argv_parse()
|
|
Content-Type: text/plain
|
|
|
|
In argv_parse(), return value of malloc should be checked
|
|
whether it is NULL, otherwise, it may cause a segfault error.
|
|
|
|
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
|
|
---
|
|
lib/support/argv_parse.c | 2 ++
|
|
1 file changed, 2 insertions(+)
|
|
|
|
diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c
|
|
index d22f6344..1f50f9e5 100644
|
|
--- a/lib/support/argv_parse.c
|
|
+++ b/lib/support/argv_parse.c
|
|
@@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
|
|
if (argv == 0) {
|
|
argv = malloc(sizeof(char *));
|
|
free(buf);
|
|
+ if (!argv)
|
|
+ return -1;
|
|
}
|
|
argv[argc] = 0;
|
|
if (ret_argc)
|
|
--
|
|
2.35.1
|
|
|