]> gitweb.ps.run Git - ps-cgit/commitdiff
cmd: fix resource leak: free allocation from cgit_currenturl and fmtalloc
authorChristian Hesse <mail@eworm.de>
Fri, 9 Oct 2015 11:15:49 +0000 (13:15 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 9 Oct 2015 12:03:58 +0000 (14:03 +0200)
Signed-off-by: Christian Hesse <mail@eworm.de>
cmd.c

diff --git a/cmd.c b/cmd.c
index c9910928a6878daef6165e258ae4ec2c6b50c20f..3093c62a5f1fc581e35d86c0d2f265cf0e4b4091 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -41,9 +41,13 @@ static void about_fn(void)
        if (ctx.repo) {
                if (!ctx.qry.path &&
                    ctx.qry.url[strlen(ctx.qry.url) - 1] != '/' &&
-                   ctx.env.path_info[strlen(ctx.env.path_info) - 1] != '/')
-                       cgit_redirect(fmtalloc("%s/", cgit_currenturl()), true);
-               else
+                   ctx.env.path_info[strlen(ctx.env.path_info) - 1] != '/') {
+                       char *currenturl = cgit_currenturl();
+                       char *redirect = fmtalloc("%s/", currenturl);
+                       cgit_redirect(redirect, true);
+                       free(currenturl);
+                       free(redirect);
+               } else
                        cgit_print_repo_readme(ctx.qry.path);
        } else
                cgit_print_site_readme();