From e84a26e32faba0c2ae7a19fa9bf805645f620e82 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 8 Nov 2022 19:17:43 +0100 Subject: unpack-file: fix ancient leak in create_temp_file() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a leak that's been with us since 3407bb4940c (Add "unpack-file" helper that unpacks a sha1 blob into a tmpfile., 2005-04-18). See 00c8fd493af (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 Signed-off-by: Taylor Blau --- builtin/unpack-file.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin/unpack-file.c') diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index 9e8119dd35..88de32b7d7 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -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; } -- cgit v1.2.3