builtin/log: fix leak when showing converted blob contents
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>
Patrick Steinhardt committed
Aug 14, 2024 at 08:52 UTC
0aaca0ec099139f12df6d66cfa09a27ec85106cc
2 files changed
+3
builtin/log.c
+1
@@ -707,6 +707,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
707
708
write_or_die(1, buf, size);
709
object_context_release(&obj_context);
710
+ free(buf);
711
return 0;
712
}
713
t/t4030-diff-textconv.sh
+2
@@ -1,6 +1,8 @@
1
#!/bin/sh
2
3
test_description='diff.*.textconv tests'
4
+
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
find_diff() {