summaryrefslogtreecommitdiff
path: root/builtin/commit-graph.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-05-18 20:05:43 -0400
committerJunio C Hamano <gitster@pobox.com>2023-05-19 09:42:26 -0700
commitc6d26a9dda59043f95ee5bf632d6aa80fa50aad7 (patch)
tree5fe01d208cb8699b85b283d23a594a52de0f1cb2 /builtin/commit-graph.c
parentcfa120947e6337e7be2658f71a0132e337ee090a (diff)
format-patch: free elements of rev.ref_message_ids list
When we are showing multiple patches with format-patch, we have to repeatedly overwrite the rev.message_id field. We take care to avoid leaking the old value by either freeing it, or adding it to ref_message_ids, a string list of ids to reference in subsequent messages. But unfortunately we do leak the value via that string list. We try to clear the string list, courtesy of 89f45cf4eb (format-patch: don't leak "extra_headers" or "ref_message_ids", 2022-04-13). But since it was initialized as "nodup", the string list doesn't realize it owns the strings, and it leaks them. We have two options here: 1. Continue to init with "nodup", but then tweak the value of ref_message_ids.strdup_strings just before clearing. 2. Init with "dup", but use "append_nodup" when transferring ownership of strings to the list. Clearing just works. I picked the second here, as I think it calls attention to the tricky part (transferring ownership via the nodup call). There's one other related fix we have to do, though. We also insert the result of clean_message_id() into the list. This _sometimes_ allocates and sometimes does not, depending on whether we have to remove cruft from the end of the string. Let's teach it to consistently return an allocated string, so that the caller knows it must be freed. There's no new test here, as the leak can already be seen in t4014.44 (as well as others in that script). We can't mark all of t4014 as leak-free, though, as there are other unrelated leaks that it triggers. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-graph.c')
0 files changed, 0 insertions, 0 deletions