Skip to content

Commit 003c1f1

Browse files
rjustogitster
authored andcommitted
config: fix a leak in git_config_copy_or_rename_section_in_file
In 52d59cc (branch: add a --copy (-c) option to go with --move (-m), 2017-06-18) a new strbuf variable was introduced, but not released. Thus, when copying a branch that has any configuration, we have a leak. $ git branch foo $ git config branch.foo.some-key some_value $ git branch -c foo bar Direct leak of 65 byte(s) in 1 object(s) allocated from: ... in xrealloc wrapper.c ... in strbuf_grow strbuf.c ... in strbuf_vaddf strbuf.c ... in strbuf_addf strbuf.c ... in store_create_section config.c ... in git_config_copy_or_rename_section_in_file config.c ... in git_config_copy_section_in_file config.c ... in git_config_copy_section config.c ... in copy_or_rename_branch builtin/branch.c ... in cmd_branch builtin/branch.c ... in run_builtin git.c Let's fix that leak. Signed-off-by: Rubén Justo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe86abd commit 003c1f1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,6 +3879,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
38793879
free(filename_buf);
38803880
config_store_data_clear(&store);
38813881
strbuf_release(&buf);
3882+
strbuf_release(&copystr);
38823883
return ret;
38833884
}
38843885

0 commit comments

Comments
 (0)