@@ -409,15 +409,15 @@ int userdiff_config(const char *k, const char *v)
if (!strcmp(type, "binary"))
return parse_tristate(&drv->binary, k, v);
if (!strcmp(type, "command"))
- return git_config_string(&drv->external, k, v);
+ return git_config_string_dup(&drv->external, k, v);
if (!strcmp(type, "textconv"))
- return git_config_string(&drv->textconv, k, v);
+ return git_config_string_dup(&drv->textconv, k, v);
if (!strcmp(type, "cachetextconv"))
return parse_bool(&drv->textconv_want_cache, k, v);
if (!strcmp(type, "wordregex"))
return git_config_string(&drv->word_regex, k, v);
if (!strcmp(type, "algorithm"))
- return git_config_string(&drv->algorithm, k, v);
+ return git_config_string_dup(&drv->algorithm, k, v);
return 0;
}
@@ -13,13 +13,13 @@ struct userdiff_funcname {
struct userdiff_driver {
const char *name;
- const char *external;
- const char *algorithm;
+ char *external;
+ char *algorithm;
int binary;
struct userdiff_funcname funcname;
const char *word_regex;
const char *word_regex_multi_byte;
- const char *textconv;
+ char *textconv;
struct notes_cache *textconv_cache;
int textconv_want_cache;
};
There are many uses of git_config_string() in the userdiff code which have the usual "leak when we see the variable multiple times" problem. We can fix many of these in the usual way by switching to the _dup() variant. But note there are some adjacent ones we cannot fix right now: funcname patterns and word regexes default to string literals, and we can't use those with our dup variant (which would try to free the literals). For now let's convert what we can. Signed-off-by: Jeff King <peff@peff.net> --- userdiff.c | 6 +++--- userdiff.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)