X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/ab350a77b1d3b0e251cc28329f2e16f0566e521e..e52a5226b83dc5232adb7d9076cae3ad4b123df4:/parsing.c diff --git a/parsing.c b/parsing.c index 151c0fe..1b2a551 100644 --- a/parsing.c +++ b/parsing.c @@ -56,6 +56,8 @@ char *substr(const char *head, const char *tail) { char *buf; + if (tail < head) + return xstrdup(""); buf = xmalloc(tail - head + 1); strncpy(buf, head, tail - head); buf[tail - head] = '\0'; @@ -125,7 +127,7 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc) struct commitinfo *cgit_parse_commit(struct commit *commit) { struct commitinfo *ret; - char *p = commit->buffer, *t = commit->buffer; + char *p = commit->buffer, *t; ret = xmalloc(sizeof(*ret)); ret->commit = commit;