Skip to content

Commit fbf7a46

Browse files
pks-tgitster
authored andcommitted
builtin/blame: fix leaking ignore revs files
When parsing the blame configuration we add "blame.ignoreRevsFile" configs to a string list. This string list is declared as with `NODUP`, and thus we hand over the allocated string to that list. We eventually end up calling `string_list_clear()` on that list, but due to it being declared as `NODUP` we will not release the associated strings and thus leak memory. Fix this issue by setting up the list as `DUP` instead and free the config string after insertion. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3332f35 commit fbf7a46

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

builtin/blame.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int no_whole_file_rename;
6767
static int show_progress;
6868
static char repeated_meta_color[COLOR_MAXLEN];
6969
static int coloring_mode;
70-
static struct string_list ignore_revs_file_list = STRING_LIST_INIT_NODUP;
70+
static struct string_list ignore_revs_file_list = STRING_LIST_INIT_DUP;
7171
static int mark_unblamable_lines;
7272
static int mark_ignored_lines;
7373

@@ -725,6 +725,7 @@ static int git_blame_config(const char *var, const char *value,
725725
if (ret)
726726
return ret;
727727
string_list_insert(&ignore_revs_file_list, str);
728+
free(str);
728729
return 0;
729730
}
730731
if (!strcmp(var, "blame.markunblamablelines")) {

t/t8013-blame-ignore-revs.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='ignore revisions when blaming'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
# Creates:

0 commit comments

Comments
 (0)