summaryrefslogtreecommitdiffabout
authorFerry Huberts <ferry.huberts@pelagic.nl>2011-03-09 07:16:58 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2011-03-26 14:13:35 (UTC)
commit3f1ebd3565afa33196dfc3e8584e04564987e33c (patch) (side-by-side diff)
tree714a4426c035416af4b4cb47bb90aecd4b3851c6
parent4d2a303c3e198c91cb6635eb66fa6f0a6c0277cc (diff)
downloadcgit-3f1ebd3565afa33196dfc3e8584e04564987e33c.zip
cgit-3f1ebd3565afa33196dfc3e8584e04564987e33c.tar.gz
cgit-3f1ebd3565afa33196dfc3e8584e04564987e33c.tar.bz2
source_filter: fix a memory leak
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 0b1b531..442b6be 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -27,48 +27,50 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
html("<tr><td class='linenumbers'><pre>");
idx = 0;
lineno = 0;
if (size) {
htmlf(numberfmt, ++lineno);
while(idx < size - 1) { // skip absolute last newline
if (buf[idx] == '\n')
htmlf(numberfmt, ++lineno);
idx++;
}
}
html("</pre></td>\n");
}
else {
html("<tr>\n");
}
if (ctx.repo->source_filter) {
html("<td class='lines'><pre><code>");
ctx.repo->source_filter->argv[1] = xstrdup(name);
cgit_open_filter(ctx.repo->source_filter);
html_raw(buf, size);
cgit_close_filter(ctx.repo->source_filter);
+ free(ctx.repo->source_filter->argv[1]);
+ ctx.repo->source_filter->argv[1] = NULL;
html("</code></pre></td></tr></table>\n");
return;
}
html("<td class='lines'><pre><code>");
html_txt(buf);
html("</code></pre></td></tr></table>\n");
}
#define ROWLEN 32
static void print_binary_buffer(char *buf, unsigned long size)
{
unsigned long ofs, idx;
static char ascii[ROWLEN + 1];
html("<table summary='blob content' class='bin-blob'>\n");
html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>");
for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) {
htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", ofs);
for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++)
htmlf("%*s%02x",
idx == 16 ? 4 : 1, "",
buf[idx] & 0xff);