]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Maŕk cgit_environment members const
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 5b20de3dd5d66fbc635edeb37bd1b589b21fc676..d145f8ab415696ae98ff6ca5e602e18976ee125f 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -401,9 +401,9 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->page.etag = NULL;
        memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list));
        if (ctx->env.script_name)
-               ctx->cfg.script_name = ctx->env.script_name;
+               ctx->cfg.script_name = xstrdup(ctx->env.script_name);
        if (ctx->env.query_string)
-               ctx->qry.raw = ctx->env.query_string;
+               ctx->qry.raw = xstrdup(ctx->env.query_string);
        if (!ctx->env.cgit_config)
                ctx->env.cgit_config = CGIT_CONFIG;
 }
@@ -427,6 +427,12 @@ static int find_current_ref(const char *refname, const unsigned char *sha1,
        return info->match;
 }
 
+static void free_refmatch_inner(struct refmatch *info)
+{
+       if (info->first_ref)
+               free(info->first_ref);
+}
+
 static char *find_default_branch(struct cgit_repo *repo)
 {
        struct refmatch info;
@@ -442,6 +448,8 @@ static char *find_default_branch(struct cgit_repo *repo)
                ref = info.first_ref;
        if (ref)
                ref = xstrdup(ref);
+       free_refmatch_inner(&info);
+
        return ref;
 }