]> git.ipfire.org Git - thirdparty/git.git/commit - ref-filter.c
ref-filter: also free head for ATOM_HEAD to avoid leak
authorAndrzej Hunt <ajrhunt@google.com>
Sun, 25 Jul 2021 13:08:24 +0000 (15:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jul 2021 19:19:20 +0000 (12:19 -0700)
commitd7cf4188e2e85faa00552b8616db31a17844df1b
tree0e4c43a5971fc0e44d908e53e199eef72629baf6
parent4e3250b7fb806f3e391239d680638ee44068ffe1
ref-filter: also free head for ATOM_HEAD to avoid leak

u.head is populated using resolve_refdup(), which returns a newly
allocated string - hence we also need to free() it.

Found while running t0041 with LSAN:

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x486804 in strdup ../projects/compiler-rt/lib/asan/asan_interceptors.cpp:452:3
    #1 0xa8be98 in xstrdup wrapper.c:29:14
    #2 0x9481db in head_atom_parser ref-filter.c:549:17
    #3 0x9408c7 in parse_ref_filter_atom ref-filter.c:703:30
    #4 0x9400e3 in verify_ref_format ref-filter.c:974:8
    #5 0x4f9e8b in print_ref_list builtin/branch.c:439:6
    #6 0x4f9e8b in cmd_branch builtin/branch.c:757:3
    #7 0x4ce83e in run_builtin git.c:475:11
    #8 0x4ccafe in handle_builtin git.c:729:3
    #9 0x4cb01c in run_argv git.c:818:4
    #10 0x4cb01c in cmd_main git.c:949:19
    #11 0x6bdc2d in main common-main.c:52:11
    #12 0x7f96edf86349 in __libc_start_main (/lib64/libc.so.6+0x24349)

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).

Signed-off-by: Andrzej Hunt <andrzej@ahunt.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref-filter.c