From c57ba191bb8838c60c1b29b11827218771a09aa8 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 25 Jul 2026 09:11:45 -1000 Subject: Skip a ref whose object cannot be parsed A dangling or unreadable ref was described through a null object. --- source/shared.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/shared.c b/source/shared.c index 5cd26a9..24f9c3c 100644 --- a/source/shared.c +++ b/source/shared.c @@ -165,9 +165,15 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const struct object_ { struct refinfo *ref; - ref = xmalloc(sizeof (struct refinfo)); + ref = xcalloc(1, sizeof (struct refinfo)); ref->refname = xstrdup(refname); ref->object = parse_object(the_repository, oid); + if (!ref->object) { + // A dangling or unreadable ref has no object to describe. + free((char *)ref->refname); + free(ref); + return NULL; + } switch (ref->object->type) { case OBJ_TAG: ref->tag = cgit_parse_tag((struct tag *)ref->object); -- cgit v2.8.0