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
@ -450,8 +450,10 @@ static void output_pair_header(struct diff_options *diffopt,
|
||||
}
|
||||
|
||||
static struct userdiff_driver section_headers = {
|
||||
.funcname = { "^ ## (.*) ##$\n"
|
||||
"^.?@@ (.*)$", REG_EXTENDED }
|
||||
.funcname = {
|
||||
.pattern = "^ ## (.*) ##$\n^.?@@ (.*)$",
|
||||
.cflags = REG_EXTENDED,
|
||||
},
|
||||
};
|
||||
|
||||
static struct diff_filespec *get_filespec(const char *name, const char *p)
|
||||
|
Reference in New Issue
Block a user