Skip to content

Commit db7d07f

Browse files
rscharfegitster
authored andcommitted
blame: handle deref_tag() returning NULL
Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e30b152 commit db7d07f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

blame.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,7 +2670,7 @@ static struct commit *find_single_final(struct rev_info *revs,
26702670
if (obj->flags & UNINTERESTING)
26712671
continue;
26722672
obj = deref_tag(revs->repo, obj, NULL, 0);
2673-
if (obj->type != OBJ_COMMIT)
2673+
if (!obj || obj->type != OBJ_COMMIT)
26742674
die("Non commit %s?", revs->pending.objects[i].name);
26752675
if (found)
26762676
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,
27012701
/* Is that sole rev a committish? */
27022702
obj = revs->pending.objects[0].item;
27032703
obj = deref_tag(revs->repo, obj, NULL, 0);
2704-
if (obj->type != OBJ_COMMIT)
2704+
if (!obj || obj->type != OBJ_COMMIT)
27052705
return NULL;
27062706

27072707
/* Do we have HEAD? */
@@ -2737,7 +2737,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
27372737
if (!(obj->flags & UNINTERESTING))
27382738
continue;
27392739
obj = deref_tag(revs->repo, obj, NULL, 0);
2740-
if (obj->type != OBJ_COMMIT)
2740+
if (!obj || obj->type != OBJ_COMMIT)
27412741
die("Non commit %s?", revs->pending.objects[i].name);
27422742
if (found)
27432743
die("More than one commit to dig up from, %s and %s?",

builtin/blame.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
820820
if (kind != OBJ_TAG)
821821
return -1;
822822
obj = deref_tag(r, parse_object(r, &oid), NULL, 0);
823+
if (!obj)
824+
return -1;
823825
oidcpy(&oid, &obj->oid);
824826
}
825827
}

0 commit comments

Comments
 (0)