about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorChristian Hesse2015-10-09 13:15:48 +0200
committerJason A. Donenfeld2015-10-09 14:02:41 +0200
commit3e244a0ccaef8303302a2c462f36b8bdf3634a46 (patch)
treed2acab80c012067c26bc853684a037cf3978c9d9 /ui-shared.c
parentui-shared: return value of cgit_currenturl is not const (diff)
downloadcgit-3e244a0ccaef8303302a2c462f36b8bdf3634a46.tar.gz
cgit-3e244a0ccaef8303302a2c462f36b8bdf3634a46.zip
ui-shared: fix resource leak: free allocation from cgit_currenturl
Coverity-id: 13927
Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ui-shared.c b/ui-shared.c index b739675..f6d38de 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -157,8 +157,11 @@ static void site_url(const char *page, const char *search, const char *sort, int
157 157
158 if (always_root || page) 158 if (always_root || page)
159 html_attr(cgit_rooturl()); 159 html_attr(cgit_rooturl());
160 else 160 else {
161 html_attr(cgit_currenturl()); 161 char *currenturl = cgit_currenturl();
162 html_attr(currenturl);
163 free(currenturl);
164 }
162 165
163 if (page) { 166 if (page) {
164 htmlf("?p=%s", page); 167 htmlf("?p=%s", page);
@@ -1020,19 +1023,21 @@ void cgit_print_pageheader(void)
1020 html("<input type='submit' value='search'/>\n"); 1023 html("<input type='submit' value='search'/>\n");
1021 html("</form>\n"); 1024 html("</form>\n");
1022 } else if (ctx.env.authenticated) { 1025 } else if (ctx.env.authenticated) {
1026 char *currenturl = cgit_currenturl();
1023 site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); 1027 site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1);
1024 if (ctx.cfg.root_readme) 1028 if (ctx.cfg.root_readme)
1025 site_link("about", "about", NULL, hc("about"), 1029 site_link("about", "about", NULL, hc("about"),
1026 NULL, NULL, 0, 1); 1030 NULL, NULL, 0, 1);
1027 html("</td><td class='form'>"); 1031 html("</td><td class='form'>");
1028 html("<form method='get' action='"); 1032 html("<form method='get' action='");
1029 html_attr(cgit_currenturl()); 1033 html_attr(currenturl);
1030 html("'>\n"); 1034 html("'>\n");
1031 html("<input type='text' name='q' size='10' value='"); 1035 html("<input type='text' name='q' size='10' value='");
1032 html_attr(ctx.qry.search); 1036 html_attr(ctx.qry.search);
1033 html("'/>\n"); 1037 html("'/>\n");
1034 html("<input type='submit' value='search'/>\n"); 1038 html("<input type='submit' value='search'/>\n");
1035 html("</form>"); 1039 html("</form>");
1040 free(currenturl);
1036 } 1041 }
1037 html("</td></tr></table>\n"); 1042 html("</td></tr></table>\n");
1038 if (ctx.env.authenticated && ctx.qry.vpath) { 1043 if (ctx.env.authenticated && ctx.qry.vpath) {