]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
ui-repolist: initialize char *buf to NULL
[ps-cgit] / ui-shared.c
index f6d38deb620de372456ea11d89eecfa6aa247f45..c04f380be52defbcfb2afb9187b61529c24e68ed 100644 (file)
@@ -54,14 +54,14 @@ const char *cgit_httpscheme(void)
                return "http://";
 }
 
-const char *cgit_hosturl(void)
+char *cgit_hosturl(void)
 {
        if (ctx.env.http_host)
-               return ctx.env.http_host;
+               return xstrdup(ctx.env.http_host);
        if (!ctx.env.server_name)
                return NULL;
        if (!ctx.env.server_port || atoi(ctx.env.server_port) == 80)
-               return ctx.env.server_name;
+               return xstrdup(ctx.env.server_name);
        return fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
 }
 
@@ -730,7 +730,7 @@ void cgit_print_docstart(void)
                return;
        }
 
-       const char *host = cgit_hosturl();
+       char *host = cgit_hosturl();
        html(cgit_doctype);
        html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
        html("<head>\n");
@@ -755,7 +755,7 @@ void cgit_print_docstart(void)
 
                html("<link rel='alternate' title='Atom feed' href='");
                html(cgit_httpscheme());
-               html_attr(cgit_hosturl());
+               html_attr(host);
                fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
                                       sb.buf);
                html_attr(fileurl);
@@ -771,6 +771,7 @@ void cgit_print_docstart(void)
        html("<body>\n");
        if (ctx.cfg.header)
                html_include(ctx.cfg.header);
+       free(host);
 }
 
 void cgit_print_docend(void)