History

ui-shared: fix resource leak: free allocation from cgit_fileurl

Christian Hesse committed 11 years ago

Commit 37fce991 parent fa5810e1 file · +11 −5Browse files

Unified · Split

ui-shared.c+11−5
@@ -746,16 +746,19 @@ void cgit_print_docstart(void) · 745 unmodified lines
746746 html("'/>\n");
747747 }
748748 if (host && ctx.repo && ctx.qry.head) {
749+ char *fileurl;
749750 struct strbuf sb = STRBUF_INIT;
750751 strbuf_addf(&sb, "h=%s", ctx.qry.head);
751752
752753 html("<link rel='alternate' title='Atom feed' href='");
753754 html(cgit_httpscheme());
754755 html_attr(cgit_hosturl());
755− html_attr(cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
756− sb.buf));
756+ fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
757+ sb.buf);
758+ html_attr(fileurl);
757759 html("' type='application/atom+xml'/>\n");
758760 strbuf_release(&sb);
761+ free(fileurl);
759762 }
760763 if (ctx.repo)
761764 cgit_add_clone_urls(print_rel_vcs_link);
@@ -997,9 +1000,12 @@ void cgit_print_pageheader(void) · 235 unmodified lines
9971000 ctx.qry.head, ctx.qry.vpath);
9981001 html("</td><td class='form'>");
9991002 html("<form class='right' method='get' action='");
1000− if (ctx.cfg.virtual_root)
1001− html_url_path(cgit_fileurl(ctx.qry.repo, "log",
1002− ctx.qry.vpath, NULL));
1003+ if (ctx.cfg.virtual_root) {
1004+ char *fileurl = cgit_fileurl(ctx.qry.repo, "log",
1005+ ctx.qry.vpath, NULL);
1006+ html_url_path(fileurl);
1007+ free(fileurl);
1008+ }
10031009 html("'>\n");
10041010 cgit_add_hidden_formfields(1, 0, "log");
10051011 html("<select name='qt'>\n");