mirror of
https://github.com/git/git.git
synced 2024-10-28 12:59:41 +01:00
convert: fix leaking config strings
In `read_convert_config()`, we end up reading some string values into variables. We don't free any potentially-existing old values though, which will result in a memory leak in case the same key has been defined multiple times. Fix those leaks. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1f08999781
commit
9642479a2b
2 changed files with 10 additions and 3 deletions
12
convert.c
12
convert.c
|
@ -1050,14 +1050,20 @@ static int read_convert_config(const char *var, const char *value,
|
||||||
* The command-line will not be interpolated in any way.
|
* The command-line will not be interpolated in any way.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!strcmp("smudge", key))
|
if (!strcmp("smudge", key)) {
|
||||||
|
FREE_AND_NULL(drv->smudge);
|
||||||
return git_config_string(&drv->smudge, var, value);
|
return git_config_string(&drv->smudge, var, value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("clean", key))
|
if (!strcmp("clean", key)) {
|
||||||
|
FREE_AND_NULL(drv->clean);
|
||||||
return git_config_string(&drv->clean, var, value);
|
return git_config_string(&drv->clean, var, value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("process", key))
|
if (!strcmp("process", key)) {
|
||||||
|
FREE_AND_NULL(drv->process);
|
||||||
return git_config_string(&drv->process, var, value);
|
return git_config_string(&drv->process, var, value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp("required", key)) {
|
if (!strcmp("required", key)) {
|
||||||
drv->required = git_config_bool(var, value);
|
drv->required = git_config_bool(var, value);
|
||||||
|
|
|
@ -5,6 +5,7 @@ test_description='blob conversion via gitattributes'
|
||||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
. "$TEST_DIRECTORY"/lib-terminal.sh
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue