summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-10-24 08:52:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-10-24 22:43:50 (GMT)
commit7059dccc6c60a872a314b19ac17702065a71d6bd (patch)
tree7fd82703079885e1adb864e8a8f185fdc6b45c8e /log-tree.c
parente230c568c4b9a991e3175e5f65171a566fd8e39c (diff)
downloadgit-7059dccc6c60a872a314b19ac17702065a71d6bd.zip
git-7059dccc6c60a872a314b19ac17702065a71d6bd.tar.gz
git-7059dccc6c60a872a314b19ac17702065a71d6bd.tar.bz2
log_tree_diff: die when we fail to parse a commit
We currently call parse_commit and then assume we can dereference the resulting "tree" struct field. If parsing failed, however, that field is NULL and we end up segfaulting. Instead of a segfault, let's print an error message and die a little more gracefully. Note that this should never happen in practice, but may happen in a corrupt repository. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/log-tree.c b/log-tree.c
index a49d8e8..11604b1 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -734,7 +734,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
return 0;
- parse_commit(commit);
+ parse_commit_or_die(commit);
sha1 = commit->tree->object.sha1;
/* Root commit? */
@@ -759,7 +759,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
* parent, showing summary diff of the others
* we merged _in_.
*/
- parse_commit(parents->item);
+ parse_commit_or_die(parents->item);
diff_tree_sha1(parents->item->tree->object.sha1,
sha1, "", &opt->diffopt);
log_tree_diff_flush(opt);
@@ -774,7 +774,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
for (;;) {
struct commit *parent = parents->item;
- parse_commit(parent);
+ parse_commit_or_die(parent);
diff_tree_sha1(parent->tree->object.sha1,
sha1, "", &opt->diffopt);
log_tree_diff_flush(opt);