From 7059dccc6c60a872a314b19ac17702065a71d6bd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Oct 2013 04:52:36 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- commit.h | 1 + 1 file changed, 1 insertion(+) (limited to 'commit.h') diff --git a/commit.h b/commit.h index d912a9d4ac..a3645dabf8 100644 --- a/commit.h +++ b/commit.h @@ -49,6 +49,7 @@ struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_n int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size); int parse_commit(struct commit *item); +void parse_commit_or_die(struct commit *item); /* Find beginning and length of commit subject. */ int find_commit_subject(const char *commit_buffer, const char **subject); -- cgit v1.2.3