diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2020-05-15 17:22:18 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2020-05-20 15:55:39 +0200 |
commit | ce8277b47ed95e71e31c933b5c6a35b24dd52756 (patch) | |
tree | 738076db8584e09f79e4342d3483656d7b695613 | |
parent | 33fdeaf3f18c02f13fb20e9a7fe8bf99e8e21cba (diff) | |
download | lvm2-ce8277b47ed95e71e31c933b5c6a35b24dd52756.tar.gz |
cov: check strdup for NULL
-rw-r--r-- | tools/command.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/command.c b/tools/command.c index 50791b169..511dda13d 100644 --- a/tools/command.c +++ b/tools/command.c @@ -2319,7 +2319,8 @@ static void _print_val_man(struct command_name *cname, int opt_enum, int val_enu } if (strchr(str, '|')) { - line = strdup(str); + if (!(line = strdup(str))) + return; _split_line(line, &line_argc, line_argv, '|'); for (i = 0; i < line_argc; i++) { if (i) @@ -3606,9 +3607,12 @@ int main(int argc, char *argv[]) goto out_free; } - if (optind < argc) - cmdname = strdup(argv[optind++]); - else { + if (optind < argc) { + if (!(cmdname = strdup(argv[optind++]))) { + log_error("Out of memory."); + goto out_free; + } + } else { log_error("Missing command name."); goto out_free; } |