From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: master - cov: check strdup for NULL
Date: Wed, 20 May 2020 14:03:19 +0000 (GMT) [thread overview]
Message-ID: <20200520140319.F2DB5395BC64@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ce8277b47ed95e71e31c933b5c6a35b24dd52756
Commit: ce8277b47ed95e71e31c933b5c6a35b24dd52756
Parent: 33fdeaf3f18c02f13fb20e9a7fe8bf99e8e21cba
Author: Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate: Fri May 15 17:22:18 2020 +0200
Committer: Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Wed May 20 15:55:39 2020 +0200
cov: check strdup for NULL
---
tools/command.c | 12 ++++++++----
1 file 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;
}
reply other threads:[~2020-05-20 14:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200520140319.F2DB5395BC64@sourceware.org \
--to=zkabelac@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.