diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Backfill an absent commit message
Diffstat (limited to 'source')
-rw-r--r--source/parsing.c20
-rw-r--r--source/ui-shared.c2
2 files changed, 14 insertions, 8 deletions
diff --git a/source/parsing.c b/source/parsing.c
index ee2b65c..a7e46de 100644
--- a/source/parsing.c
+++ b/source/parsing.c
@@ -175,14 +175,20 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
p = next_header_line(p);
while (p && *p == '\n')
p++;
- if (!p)
- return ret;
- t = strchrnul(p, '\n');
- ret->subject = substr(p, t);
- while (*t == '\n')
- t++;
- ret->msg = xstrdup(t);
+ if (p) {
+ t = strchrnul(p, '\n');
+ ret->subject = substr(p, t);
+ while (*t == '\n')
+ t++;
+ ret->msg = xstrdup(t);
+ } else {
+ // A crafted commit can end right after its headers with no
+ // message. Keep subject and msg as empty strings so callers
+ // can treat them as text unconditionally.
+ ret->subject = xstrdup("");
+ ret->msg = xstrdup("");
+ }
reencode(&ret->author, ret->msg_encoding, PAGE_ENCODING);
reencode(&ret->author_email, ret->msg_encoding, PAGE_ENCODING);
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 7687ae1..3ec4f55 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -436,7 +436,7 @@ void cgit_commit_link(const char *name, const char *title, const char *class,
html("follow=1");
}
html("'>");
- if (name[0] != '\0') {
+ if (name && name[0] != '\0') {
if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
html_ntxt(name, ctx.cfg.max_msg_len - 3);
html("...");