From 2c70e914664e5afda521d306524d4e6869b57001 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 8 Aug 2026 12:50:08 -1000 Subject: Stop the index and the log repeating work --- source/parsing.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/parsing.c') diff --git a/source/parsing.c b/source/parsing.c index f6b1a02..0d63b51 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -62,12 +62,18 @@ void cgit_parse_url(const char *url) static char *substr(const char *head, const char *tail) { + size_t len; char *buf; if (tail < head) return xstrdup(""); - buf = xmalloc(tail - head + 1); - strlcpy(buf, head, tail - head + 1); + // head points into the commit buffer, so strlcpy would measure the + // whole remaining commit just to copy a name or a subject off the front + // of it. + len = tail - head; + buf = xmalloc(len + 1); + memcpy(buf, head, len); + buf[len] = '\0'; return buf; } -- cgit v2.8.0