List for cgit developers and users
 help / color / mirror / Atom feed
From: list at eworm.de (Christian Hesse)
Subject: [PATCH 2/8] ui-ssdiff: fix resource leak: free allocation from cgit_fileurl
Date: Fri,  9 Oct 2015 13:15:45 +0200	[thread overview]
Message-ID: <1444389351-2154-2-git-send-email-list@eworm.de> (raw)
In-Reply-To: <1444389351-2154-1-git-send-email-list@eworm.de>

From: Christian Hesse <mail at eworm.de>

Coverity-id: 13929
Signed-off-by: Christian Hesse <mail at eworm.de>
---
 ui-ssdiff.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index 2146c71..d183d40 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -230,11 +230,13 @@ static void print_ssdiff_line(char *class,
 		struct diff_filespec *old_file = cgit_get_current_old_file();
 		char *lineno_str = fmt("n%d", old_line_no);
 		char *id_str = fmt("id=%s#%s", is_null_sha1(old_file->sha1)?"HEAD":sha1_to_hex(old_rev_sha1), lineno_str);
+		char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str);
 		html("<td class='lineno'><a href='");
-		html(cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str));
+		html(fileurl);
 		htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
 		html("</td>");
 		htmlf("<td class='%s'>", class);
+		free(fileurl);
 	} else if (old_line)
 		htmlf("<td class='lineno'></td><td class='%s'>", class);
 	else
@@ -251,11 +253,13 @@ static void print_ssdiff_line(char *class,
 		struct diff_filespec *new_file = cgit_get_current_new_file();
 		char *lineno_str = fmt("n%d", new_line_no);
 		char *id_str = fmt("id=%s#%s", is_null_sha1(new_file->sha1)?"HEAD":sha1_to_hex(new_rev_sha1), lineno_str);
+		char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str);
 		html("<td class='lineno'><a href='");
-		html(cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str));
+		html(fileurl);
 		htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
 		html("</td>");
 		htmlf("<td class='%s'>", class);
+		free(fileurl);
 	} else if (new_line)
 		htmlf("<td class='lineno'></td><td class='%s'>", class);
 	else
-- 
2.6.1



  reply	other threads:[~2015-10-09 11:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 11:15 [PATCH 1/8] ui-tree: fix resource leak: free before return list
2015-10-09 11:15 ` list [this message]
2015-10-09 11:59   ` [PATCH 2/8] ui-ssdiff: fix resource leak: free allocation from cgit_fileurl Jason
2015-10-09 11:15 ` [PATCH 3/8] ui-shared: " list
2015-10-09 11:15 ` [PATCH 4/8] ui-shared: return value of cgit_currenturl is not const list
2015-10-09 12:01   ` Jason
2015-10-09 11:15 ` [PATCH 5/8] ui-shared: fix resource leak: free allocation from cgit_currenturl list
2015-10-09 12:02   ` Jason
2015-10-09 11:15 ` [PATCH 6/8] cmd: fix resource leak: free allocation from cgit_currenturl and fmtalloc list
2015-10-09 12:03   ` Jason
2015-10-09 12:08     ` list
2015-10-09 12:13       ` mailings
2015-10-09 12:16         ` list
2015-10-09 12:25           ` Jason
2015-10-09 11:15 ` [PATCH 7/8] ui-shared: return value of cgit_hosturl is not const list
2015-10-09 12:04   ` Jason
2015-10-09 11:15 ` [PATCH 8/8] ui-shared: fix resource leak: free allocation from cgit_hosturl list
2015-10-09 12:04   ` Jason
2015-10-09 12:13     ` list
2015-10-09 11:58 ` [PATCH 1/8] ui-tree: fix resource leak: free before return Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444389351-2154-2-git-send-email-list@eworm.de \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).