[PATCH 04/14] unparse_commit(): defensive programming
From: Johannes Schindelin <johannes.schindelin@gmx.de>
CodeQL points out that `lookup_commit()` can return NULL values.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
commit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commit.c b/commit.c
index 6efdb03997d9..1cbc798e32ba 100644
--- a/commit.c
+++ b/commit.c
@@ -187,7 +187,7 @@ void unparse_commit(struct repository *r, const struct object_id *oid)
{
struct commit *c = lookup_commit(r, oid);
- if (!c->object.parsed)
+ if (!c || !c->object.parsed)
return;
free_commit_list(c->parents);
c->parents = NULL;
--
gitgitgadget