git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] blame: handle deref_tag() returning NULL

From
René Scharfe <l.s.r@web.de>
Date
Oct 11, 2020, 16:03 UTC
Message-ID
<3cf2bcfb-521d-0f4f-a8cb-8d6507c69f35@web.de>
Signed-off-by: René Scharfe <l.s.r@web.de>
---
 blame.c         | 6 +++---
 builtin/blame.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/blame.c b/blame.c
index 686845b2b4..de7b5d411f 100644
--- a/blame.c
+++ b/blame.c
@@ -2670,7 +2670,7 @@ static struct commit *find_single_final(struct rev_info *revs,
 		if (obj->flags & UNINTERESTING)
 			continue;
 		obj = deref_tag(revs->repo, obj, NULL, 0);
-		if (obj->type != OBJ_COMMIT)
+		if (!obj || obj->type != OBJ_COMMIT)
 			die("Non commit %s?", revs->pending.objects[i].name);
 		if (found)
 			die("More than one commit to dig from %s and %s?",
@@ -2701,7 +2701,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
 	/* Is that sole rev a committish? */
 	obj = revs->pending.objects[0].item;
 	obj = deref_tag(revs->repo, obj, NULL, 0);
-	if (obj->type != OBJ_COMMIT)
+	if (!obj || obj->type != OBJ_COMMIT)
 		return NULL;

 	/* Do we have HEAD? */
@@ -2737,7 +2737,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
 		if (!(obj->flags & UNINTERESTING))
 			continue;
 		obj = deref_tag(revs->repo, obj, NULL, 0);
-		if (obj->type != OBJ_COMMIT)
+		if (!obj || obj->type != OBJ_COMMIT)
 			die("Non commit %s?", revs->pending.objects[i].name);
 		if (found)
 			die("More than one commit to dig up from, %s and %s?",
diff --git a/builtin/blame.c b/builtin/blame.c
index bb0f29300e..b5036ab327 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
 		if (kind != OBJ_TAG)
 			return -1;
 		obj = deref_tag(r, parse_object(r, &oid), NULL, 0);
+		if (!obj)
+			return -1;
 		oidcpy(&oid, &obj->oid);
 	}
 }
--
2.28.0
Message 1 of 1 in “blame: handle deref_tag() returning NULL”
  1. blame: handle deref_tag() returning NULLRené Scharfe, Oct 11, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.