From 42adaa11aa0a66645d4cf94488c88660cea00c41 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 21 Sep 2026 21:34:12 -1000 Subject: Harden the page renderers --- source/ui-plain.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source/ui-plain.c') diff --git a/source/ui-plain.c b/source/ui-plain.c index 6b45637..959b1bf 100644 --- a/source/ui-plain.c +++ b/source/ui-plain.c @@ -15,10 +15,8 @@ #include "ui-plain.h" #include "ui-shared.h" -/* - * A listing is opened by the entry that matched and closed only once the walk - * is over, so the end of the page has to tell the three cases apart. - */ +// A listing is opened by the entry that matched and closed only once the walk +// is over, so the end of the page has to tell the three cases apart. enum response { RESPONSE_NONE, RESPONSE_BLOB, @@ -133,9 +131,9 @@ static void print_dir(const char *base, int baselen, const char *path) // cgit_plain_link is asked for with a null path. fullpath[len - 1] = 0; slash = strrchr(fullpath, '/'); - if (slash) + if (slash) { *(slash + 1) = 0; - else { + } else { free(fullpath); fullpath = NULL; } @@ -199,6 +197,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, static int dir_prefix_len(const char *path) { const char *slash = strrchr(path, '/'); + if (slash) return slash - path + 1; return 0; -- cgit v2.8.0