diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Skip a ref whose object cannot be parsed
A dangling or unreadable ref was described through a null object.
Diffstat (limited to 'source')
| -rw-r--r-- | 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); |
