about summary refs log tree commit diff stats
path: root/ui-ssdiff.c
diff options
context:
space:
mode:
authorChristian Hesse2015-10-09 13:15:45 +0200
committerJason A. Donenfeld2015-10-09 13:59:24 +0200
commitfa5810ed8e66c4b217b8e02d2682e0fdba7f102b (patch)
treeb39ae5cf1e824c5b57066d9d977da8fc90475f86 /ui-ssdiff.c
parentui-tree: fix resource leak: free before return (diff)
downloadcgit-fa5810ed8e66c4b217b8e02d2682e0fdba7f102b.tar.gz
cgit-fa5810ed8e66c4b217b8e02d2682e0fdba7f102b.zip
ui-ssdiff: fix resource leak: free allocation from cgit_fileurl
Coverity-id: 13929
Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'ui-ssdiff.c')
-rw-r--r--ui-ssdiff.c8
1 files 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,
230 struct diff_filespec *old_file = cgit_get_current_old_file(); 230 struct diff_filespec *old_file = cgit_get_current_old_file();
231 char *lineno_str = fmt("n%d", old_line_no); 231 char *lineno_str = fmt("n%d", old_line_no);
232 char *id_str = fmt("id=%s#%s", is_null_sha1(old_file->sha1)?"HEAD":sha1_to_hex(old_rev_sha1), lineno_str); 232 char *id_str = fmt("id=%s#%s", is_null_sha1(old_file->sha1)?"HEAD":sha1_to_hex(old_rev_sha1), lineno_str);
233 char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str);
233 html("<td class='lineno'><a href='"); 234 html("<td class='lineno'><a href='");
234 html(cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str)); 235 html(fileurl);
235 htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1); 236 htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
236 html("</td>"); 237 html("</td>");
237 htmlf("<td class='%s'>", class); 238 htmlf("<td class='%s'>", class);
239 free(fileurl);
238 } else if (old_line) 240 } else if (old_line)
239 htmlf("<td class='lineno'></td><td class='%s'>", class); 241 htmlf("<td class='lineno'></td><td class='%s'>", class);
240 else 242 else
@@ -251,11 +253,13 @@ static void print_ssdiff_line(char *class,
251 struct diff_filespec *new_file = cgit_get_current_new_file(); 253 struct diff_filespec *new_file = cgit_get_current_new_file();
252 char *lineno_str = fmt("n%d", new_line_no); 254 char *lineno_str = fmt("n%d", new_line_no);
253 char *id_str = fmt("id=%s#%s", is_null_sha1(new_file->sha1)?"HEAD":sha1_to_hex(new_rev_sha1), lineno_str); 255 char *id_str = fmt("id=%s#%s", is_null_sha1(new_file->sha1)?"HEAD":sha1_to_hex(new_rev_sha1), lineno_str);
256 char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str);
254 html("<td class='lineno'><a href='"); 257 html("<td class='lineno'><a href='");
255 html(cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str)); 258 html(fileurl);
256 htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1); 259 htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1);
257 html("</td>"); 260 html("</td>");
258 htmlf("<td class='%s'>", class); 261 htmlf("<td class='%s'>", class);
262 free(fileurl);
259 } else if (new_line) 263 } else if (new_line)
260 htmlf("<td class='lineno'></td><td class='%s'>", class); 264 htmlf("<td class='lineno'></td><td class='%s'>", class);
261 else 265 else