Message ID | 20210630082724.50838-8-wuguanghao3@huawei.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,01/12] profile_create_node: set magic before strdup(name) to avoid memory leak | expand |
On Wed, Jun 30, 2021 at 04:27:19PM +0800, wuguanghao wrote: > From: Zhiqiang Liu <liuzhiqiang26@huawei.com> > > In argv_parse(), return value of malloc should be checked > whether it is NULL, otherwise, it may cause a segfault error. Thanks, applied. - Ted
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)