summaryrefslogtreecommitdiffstats
path: root/userdiff.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-14 08:52:50 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-14 19:08:01 +0200
commit38678e5df55b77e98b47e7847faf83451eb161de (patch)
tree53a018a71f6eb23f5bfe88a0494ae635caa807a6 /userdiff.h
parentbuiltin/format-patch: fix various trivial memory leaks (diff)
downloadgit-38678e5df55b77e98b47e7847faf83451eb161de.tar.xz
git-38678e5df55b77e98b47e7847faf83451eb161de.zip
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>
Diffstat (limited to '')
-rw-r--r--userdiff.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/userdiff.h b/userdiff.h
index 7565930337..827361b0bc 100644
--- a/userdiff.h
+++ b/userdiff.h
@@ -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;
};