@@ -52,7 +52,7 @@ static enum help_action {
HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,
} cmd_mode;
-static const char *html_path;
+static char *html_path;
static int verbose = 1;
static enum help_format help_format = HELP_FORMAT_NONE;
static int exclude_guides;
@@ -407,10 +407,7 @@ static int git_help_config(const char *var, const char *value,
return 0;
}
if (!strcmp(var, "help.htmlpath")) {
- if (!value)
- return config_error_nonbool(var);
- html_path = xstrdup(value);
- return 0;
+ return git_config_string_dup(&html_path, var, value);
}
if (!strcmp(var, "man.viewer")) {
if (!value)
@@ -1575,12 +1575,8 @@ static int git_default_core_config(const char *var, const char *value,
if (!strcmp(var, "core.checkroundtripencoding"))
return git_config_string(&check_roundtrip_encoding, var, value);
- if (!strcmp(var, "core.notesref")) {
- if (!value)
- return config_error_nonbool(var);
- notes_ref_name = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "core.notesref"))
+ return git_config_string_dup(¬es_ref_name, var, value);
if (!strcmp(var, "core.editor"))
return git_config_string(&editor_program, var, value);
@@ -308,8 +308,6 @@ static int read_merge_config(const char *var, const char *value,
return git_config_string(&fn->description, var, value);
if (!strcmp("driver", key)) {
- if (!value)
- return config_error_nonbool(var);
/*
* merge.<name>.driver specifies the command line:
*
@@ -333,8 +331,7 @@ static int read_merge_config(const char *var, const char *value,
* file named by %A, and signal that it has done with zero exit
* status.
*/
- fn->cmdline = xstrdup(value);
- return 0;
+ return git_config_string_dup(&fn->cmdline, var, value);
}
if (!strcmp("recursive", key))
These are cases which open-code the equivalent of git_config_string(), but end up leaking the resulting value if the config value is seen multiple times (because they never free an existing value). Using git_config_string_dup() plug these potential leaks. Signed-off-by: Jeff King <peff@peff.net> --- builtin/help.c | 7 ++----- config.c | 8 ++------ merge-ll.c | 5 +---- 3 files changed, 5 insertions(+), 15 deletions(-)