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>
This commit is contained in:

committed by
Junio C Hamano

parent
e230c568c4
commit
7059dccc6c
7
commit.c
7
commit.c
@ -341,6 +341,13 @@ int parse_commit(struct commit *item)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void parse_commit_or_die(struct commit *item)
|
||||
{
|
||||
if (parse_commit(item))
|
||||
die("unable to parse commit %s",
|
||||
item ? sha1_to_hex(item->object.sha1) : "(null)");
|
||||
}
|
||||
|
||||
int find_commit_subject(const char *commit_buffer, const char **subject)
|
||||
{
|
||||
const char *eol;
|
||||
|
Reference in New Issue
Block a user