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 <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Zhiqiang Liu 2021-06-30 16:27:19 +08:00 committed by Theodore Ts'o
parent af03924f5b
commit a61bc9e009

View File

@ -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)