summaryrefslogtreecommitdiff
path: root/compat/regex/regex.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-09-09 19:16:53 -0400
committerJunio C Hamano <gitster@pobox.com>2024-09-09 16:26:10 -0700
commite595b016fc4ab20b87b935d29cf689fd956d8588 (patch)
tree56ff53417f4172f7b753e232ff39be8a5a4903b1 /compat/regex/regex.c
parenta2417a03c92d5a1cbd7d9b7e787e9d3882ad8842 (diff)
ref-filter: store ref_trailer_buf data per-atom
The trailer API takes options via a trailer_opts struct. Some of those options point to data structures which require extra storage. Those structures aren't actually embedded in the options struct, but rather we pass pointers, and the caller is responsible for managing them. This is a little convoluted, but makes sense since some of them are not even concrete (e.g., you can pass a filter function and a void data pointer, but the trailer code doesn't even know what's in the pointer). When for-each-ref, etc, parse the %(trailers) placeholder, they stuff the extra data into a ref_trailer_buf struct. But we only hold a single static global instance of this struct. So if a format string has multiple %(trailer) placeholders, they'll stomp on each other: the "key" list will end up with entries for all of them, and the separator buffers will use the values from whichever was parsed last. Instead, we should have a ref_trailer_buf for each instance of the placeholder, and store it alongside the trailer_opts in the used_atom structure. And that's what this patch does. Note that we also have to add code to clean them up in ref_array_clear(). The original code did not bother cleaning them up, but it wasn't technically a "leak" since they were still reachable from the static global instance. Reported-by: Brooke Kuhlmann <brooke@alchemists.io> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/regex/regex.c')
0 files changed, 0 insertions, 0 deletions