From: john at keeping.me.uk (John Keeping)
Subject: [PATCH 1/3] ui-log: handle parse_commit() errors
Date: Sat, 16 Jan 2016 11:03:05 +0000 [thread overview]
Message-ID: <daf4760ad52967fb12399b35854b7bd3018e860c.1452942146.git.john@keeping.me.uk> (raw)
In-Reply-To: <cover.1452942146.git.john@keeping.me.uk>
If parse_commit() fails, none of the fields in the commit structure will
have been populated so we will dereference NULL when accessing
item->tree.
There isn't much we can do about the error at this point, but if we
return true then we'll try parsing the commit again from print_commit()
and we can report an error to the user at that point.
Coverity-id: 13801
Signed-off-by: John Keeping <john at keeping.me.uk>
---
ui-log.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ui-log.c b/ui-log.c
index 4573255..a4dc707 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -141,7 +141,9 @@ static int show_commit(struct commit *commit, struct rev_info *revs)
/* When we get here we have precisely one parent. */
parent = parents->item;
- parse_commit(parent);
+ /* If we can't parse the commit, let print_commit() report an error. */
+ if (parse_commit(parent))
+ return 1;
files = 0;
add_lines = 0;
--
2.7.0.226.gfe986fe
next prev parent reply other threads:[~2016-01-16 11:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-16 11:03 [PATCH 0/3] Fix some issues found by Coverity john
2016-01-16 11:03 ` john [this message]
2016-01-16 11:03 ` [PATCH 2/3] cache: use size_t for string lengths john
2016-01-16 11:03 ` [PATCH 3/3] cache: don't check for match with no key john
2016-01-17 16:04 ` [PATCH 0/3] Fix some issues found by Coverity Jason
2016-01-17 16:19 ` Jason
2016-01-17 20:25 ` john
2016-02-03 4:46 ` mathstuf
2016-02-08 13:35 ` Jason
2016-02-08 14:16 ` john
2016-02-08 14:33 ` Jason
2016-02-08 16:31 ` john
2016-02-08 17:26 ` Jason
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=daf4760ad52967fb12399b35854b7bd3018e860c.1452942146.git.john@keeping.me.uk \
--to=cgit@lists.zx2c4.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).