Diff options
-rw-r--r--source/cgit.c8
1 file changed, 6 insertions, 2 deletions
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();