]> granicus.if.org Git - cgit/commitdiff
cgit_print_commit(): Free tmp variable
authorLukas Fleischer <cgit@cryptocrack.de>
Mon, 4 Mar 2013 12:25:37 +0000 (13:25 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 5 Mar 2013 01:47:53 +0000 (20:47 -0500)
Fixes following memory leak seen with "PATH_INFO=/cgit/commit/":

    ==16894== 7 bytes in 1 blocks are definitely lost in loss record 4 of 92
    ==16894==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16894==    by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so)
    ==16894==    by 0x46CAC8: xstrdup (wrapper.c:35)
    ==16894==    by 0x40CD6F: cgit_print_commit (ui-commit.c:70)
    ==16894==    by 0x407B06: commit_fn (cmd.c:54)
    ==16894==    by 0x405E16: process_request (cgit.c:574)
    ==16894==    by 0x4074C8: cache_process (cache.c:322)
    ==16894==    by 0x406C4F: main (cgit.c:872)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
ui-commit.c

index 74f37c8a0ff4222c13e410635fc0fac3d0ba9049..078328529b54fd15f7e1f6eacc013c9a97cfcb53 100644 (file)
@@ -74,6 +74,7 @@ void cgit_print_commit(char *hex, const char *prefix)
                html(" /");
                cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
        }
+       free(tmp);
        html("</td></tr>\n");
        for (p = commit->parents; p; p = p->next) {
                parent = lookup_commit_reference(p->item->object.sha1);