diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-27 13:46:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-27 20:19:59 +0200 |
commit | a6cb0cc61033d10eb948057c45dea25c1ab8e151 (patch) | |
tree | 2d5b443acc17c1a5b497ad903eef4a4615240ef7 /config.c | |
parent | diff: refactor code to clarify memory ownership of prefixes (diff) | |
download | git-a6cb0cc61033d10eb948057c45dea25c1ab8e151.tar.xz git-a6cb0cc61033d10eb948057c45dea25c1ab8e151.zip |
convert: refactor code to clarify ownership of check_roundtrip_encoding
The `check_roundtrip_encoding` variable is tracked in a `const char *`
even though it may contain allocated strings at times. The result is
that those strings may be leaking because we never free them.
Refactor the code to always store allocated strings in this variable.
The default value is handled in `check_roundtrip()` now, which is the
only user of the variable.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1564,8 +1564,10 @@ static int git_default_core_config(const char *var, const char *value, return 0; } - if (!strcmp(var, "core.checkroundtripencoding")) - return git_config_string(&check_roundtrip_encoding, var, value); + if (!strcmp(var, "core.checkroundtripencoding")) { + FREE_AND_NULL(check_roundtrip_encoding); + return git_config_string((const char **) &check_roundtrip_encoding, var, value); + } if (!strcmp(var, "core.notesref")) { if (!value) |