From: Zhiqiang Liu Date: Wed, 30 Jun 2021 08:27:19 +0000 (+0800) Subject: argv_parse: check return value of malloc in argv_parse() X-Git-Tag: v1.46.3~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a61bc9e009b4b829f61f1717753b4ee0882d9aba;p=thirdparty%2Fe2fsprogs.git argv_parse: check return value of malloc in argv_parse() 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 Signed-off-by: Wu Guanghao Signed-off-by: Theodore Ts'o --- diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c index d22f6344c..1f50f9e57 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)