diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-03-04 19:32:15 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-04 22:24:19 +0100 |
commit | 4998e93fa6e0da45440dd344419974e46d81a165 (patch) | |
tree | 5f8ed32c791dd6428225691501ef1e557bc18171 /range-diff.c | |
parent | lockfile API users: simplify and don't leak "path" (diff) | |
download | git-4998e93fa6e0da45440dd344419974e46d81a165.tar.xz git-4998e93fa6e0da45440dd344419974e46d81a165.zip |
range-diff: plug memory leak in common invocation
Create a public release_patch() version of the private free_patch()
function added in 13b5af22f39 (apply: move libified code from
builtin/apply.c to apply.{c,h}, 2016-04-22). Unlike the existing
function this one doesn't free() the "struct patch" itself, so we can
use it for variables on the stack.
Use it in range-diff.c to fix a memory leak in common range-diff
invocations, e.g.:
git -P range-diff origin/master origin/next origin/seen
Would emit several errors when compiled with SANITIZE=leak, but now
runs cleanly.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | range-diff.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/range-diff.c b/range-diff.c index 30a4de5c2d..b2a2961f52 100644 --- a/range-diff.c +++ b/range-diff.c @@ -165,6 +165,7 @@ static int read_patches(const char *range, struct string_list *list, patch.old_mode, patch.new_mode); strbuf_addstr(&buf, " ##"); + release_patch(&patch); } else if (in_header) { if (starts_with(line, "Author: ")) { strbuf_addstr(&buf, " ## Metadata ##\n"); |