From 4208273cd1f03742fbbbed6f45befd9e663305b4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:55:46 -0700 Subject: Keep the repository title in one static buffer --- source/cgit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/cgit.c b/source/cgit.c index cf93881..38f30a0 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -1093,11 +1093,14 @@ static void open_repo(int *nongit, int *err) */ static int prepare_repo_cmd(int nongit, int err, int clone) { + // Static, since the pages replace the title without freeing it. + static struct strbuf title = STRBUF_INIT; struct object_id oid; if (nongit) { const char *name = ctx.repo->name; - ctx.page.title = xstrfmt("%s - %s", ctx.cfg.root_title, "config error"); + strbuf_addf(&title, "%s - %s", ctx.cfg.root_title, "config error"); + ctx.page.title = title.buf; ctx.repo = NULL; cgit_print_error_page( 404, "Not Found", "Failed to open %s: %s", name, @@ -1105,7 +1108,8 @@ static int prepare_repo_cmd(int nongit, int err, int clone) ); return 1; } - ctx.page.title = xstrfmt("%s - %s", ctx.repo->name, ctx.cfg.root_title); + strbuf_addf(&title, "%s - %s", ctx.repo->name, ctx.cfg.root_title); + ctx.page.title = title.buf; if (!ctx.repo->defbranch) ctx.repo->defbranch = guess_defbranch(); -- cgit