]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/log: fix leak when showing converted blob contents
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:53 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:08:01 +0000 (10:08 -0700)
In `show_blob_object()`, we proactively call `textconv_object()`. In
case we have a textconv driver for this blob we will end up showing the
converted contents, otherwise we'll show the un-converted contents of it
instead.

When the object has been converted we never free the buffer containing
the converted contents. Fix this to plug this memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
t/t4030-diff-textconv.sh

index f5cb00c64301e0d5110ffbe6c78189ce33b0d53d..36769bab3b69a97744b6fe92437f7b06ce5d62c6 100644 (file)
@@ -707,6 +707,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
 
        write_or_die(1, buf, size);
        object_context_release(&obj_context);
+       free(buf);
        return 0;
 }
 
index a39a626664d4a529be3d7978fad831e35e224e8c..29f6d610c2e61bc80a7b9fa64f8212d6f2a9384d 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='diff.*.textconv tests'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 find_diff() {