]> gitweb.ps.run Git - ps-cgit/commitdiff
Fix qry.head leak on error
authorRichard Maw <richard.maw@gmail.com>
Sat, 2 Jul 2016 19:28:10 +0000 (20:28 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 11 Jul 2016 23:06:04 +0000 (01:06 +0200)
This is run soon before exiting so it wasn't leaked for long.

Signed-off-by: Richard Maw <richard.maw@gmail.com>
cgit.c

diff --git a/cgit.c b/cgit.c
index ab3fadbc5e51bef7e8061f31f8cc2af8287c47d8..9427c4a2752c9fe321da795ee279987afb12092f 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -616,11 +616,11 @@ static int prepare_repo_cmd(void)
        }
 
        if (get_sha1(ctx.qry.head, sha1)) {
-               char *tmp = xstrdup(ctx.qry.head);
-               ctx.qry.head = ctx.repo->defbranch;
+               char *old_head = ctx.qry.head;
+               ctx.qry.head = xstrdup(ctx.repo->defbranch);
                cgit_print_error_page(404, "Not found",
-                               "Invalid branch: %s", tmp);
-               free(tmp);
+                               "Invalid branch: %s", old_head);
+               free(old_head);
                return 1;
        }
        string_list_sort(&ctx.repo->submodules);