Skip to content

Commit e84a26e

Browse files
avargitster
authored andcommitted
unpack-file: fix ancient leak in create_temp_file()
Fix a leak that's been with us since 3407bb4 (Add "unpack-file" helper that unpacks a sha1 blob into a tmpfile., 2005-04-18). See 00c8fd4 (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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent b6046ab commit e84a26e

File tree

6 files changed

+8
-0
lines changed

6 files changed

+8
-0
lines changed

builtin/unpack-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static char *create_temp_file(struct object_id *oid)
1919
if (write_in_full(fd, buf, size) < 0)
2020
die_errno("unable to write temp-file");
2121
close(fd);
22+
free(buf);
2223
return path;
2324
}
2425

t/t6060-merge-index.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='basic git merge-index / git-merge-one-file tests'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup diverging branches' '

t/t6401-merge-criss-cross.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
test_description='Test criss-cross merge'
11+
12+
TEST_PASSES_SANITIZE_LEAK=true
1113
. ./test-lib.sh
1214

1315
test_expect_success 'prepare repository' '

t/t6406-merge-attr.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test_description='per path merge controlled by merge attribute'
88
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
99
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

11+
TEST_PASSES_SANITIZE_LEAK=true
1112
. ./test-lib.sh
1213

1314
test_expect_success setup '

t/t6407-merge-binary.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='ask merge-recursive to merge binary files'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
test_expect_success setup '

t/t7605-merge-resolve.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='git merge
44
55
Testing the resolve strategy.'
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
test_expect_success 'setup' '

0 commit comments

Comments
 (0)