unpack-file: fix ancient leak in create_temp_file()
Fix a leak that's been with us since3407bb4940
(Add "unpack-file" helper that unpacks a sha1 blob into a tmpfile., 2005-04-18). See00c8fd493a
(cat-file: use streaming API to print blobs, 2012-03-07) for prior art which shows the same API pattern, i.e. free()-ing the result of read_object_file() after it's used. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
parent
b6046abc0c
commit
e84a26e32f
@ -19,6 +19,7 @@ static char *create_temp_file(struct object_id *oid)
|
||||
if (write_in_full(fd, buf, size) < 0)
|
||||
die_errno("unable to write temp-file");
|
||||
close(fd);
|
||||
free(buf);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic git merge-index / git-merge-one-file tests'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup diverging branches' '
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
|
||||
test_description='Test criss-cross merge'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'prepare repository' '
|
||||
|
@ -8,6 +8,7 @@ test_description='per path merge controlled by merge attribute'
|
||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
@ -5,6 +5,7 @@ test_description='ask merge-recursive to merge binary files'
|
||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
@ -4,6 +4,7 @@ test_description='git merge
|
||||
|
||||
Testing the resolve strategy.'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
Loading…
Reference in New Issue
Block a user