userdiff: fix leaking memory for configured diff drivers
The userdiff structures may be initialized either statically on the stack or dynamically via configuration keys. In the latter case we end up leaking memory because we didn't have any infrastructure to discern those strings which have been allocated statically and those which have been allocated dynamically. Refactor the code such that we have two pointers for each of these strings: one that holds the value as accessed by other subsystems, and one that points to the same string in case it has been allocated. Like this, we can safely free the second pointer and thus plug those memory leaks. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1bc158e750
commit
38678e5df5
@ -8,6 +8,7 @@ struct repository;
|
||||
|
||||
struct userdiff_funcname {
|
||||
const char *pattern;
|
||||
char *pattern_owned;
|
||||
int cflags;
|
||||
};
|
||||
|
||||
@ -20,11 +21,14 @@ struct userdiff_driver {
|
||||
const char *name;
|
||||
struct external_diff external;
|
||||
const char *algorithm;
|
||||
char *algorithm_owned;
|
||||
int binary;
|
||||
struct userdiff_funcname funcname;
|
||||
const char *word_regex;
|
||||
char *word_regex_owned;
|
||||
const char *word_regex_multi_byte;
|
||||
const char *textconv;
|
||||
char *textconv_owned;
|
||||
struct notes_cache *textconv_cache;
|
||||
int textconv_want_cache;
|
||||
};
|
||||
|
Reference in New Issue
Block a user