mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
range-diff: plug memory leak in common invocation
Create a public release_patch() version of the private free_patch()
function added in 13b5af22f3 (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>
This commit is contained in:
committed by
Junio C Hamano
parent
ef3fe21448
commit
4998e93fa6
2
apply.h
2
apply.h
@@ -173,6 +173,8 @@ int parse_git_diff_header(struct strbuf *root,
|
||||
unsigned int size,
|
||||
struct patch *patch);
|
||||
|
||||
void release_patch(struct patch *patch);
|
||||
|
||||
/*
|
||||
* Some aspects of the apply behavior are controlled by the following
|
||||
* bits in the "options" parameter passed to apply_all_patches().
|
||||
|
||||
Reference in New Issue
Block a user