mbox series

[0/6] apply: fix leaking buffer of `struct image`

Message ID cover.1726470385.git.ps@pks.im (mailing list archive)
Headers show
Series apply: fix leaking buffer of `struct image` | expand

Message

Patrick Steinhardt Sept. 16, 2024, 7:09 a.m. UTC
Hi,

this patch series addresses memory leaks in "apply.c" revolving around
`struct image`. I've split the series out of the usual leak fix series
because I found the code really hard to reason about. So instead of just
trying to plug the leak with a least-effort patch I refactored it a bit
to make it more straight-forward. Most importantly, the last patch
converts the code to use a proper `struct strbuf` to modify the pre- and
postimages, which is both easier and allows for proper lifecycle
management of its buffer.

This series builds on top of ed155187b4 (Sync with Git 2.46.1,
2024-09-13).

Thanks!

Patrick

Patrick Steinhardt (6):
  apply: reorder functions to move image-related things together
  apply: rename functions operating on `struct image`
  apply: introduce macro and function to init images
  apply: refactor code to drop `line_allocated`
  apply: rename members that track line count and allocation length
  apply: refactor `struct image` to use a `struct strbuf`

 apply.c                            | 447 +++++++++++++----------------
 t/t3436-rebase-more-options.sh     |   1 +
 t/t4107-apply-ignore-whitespace.sh |   4 +-
 t/t4124-apply-ws-rule.sh           |   1 +
 t/t4125-apply-ws-fuzz.sh           |   1 +
 t/t4138-apply-ws-expansion.sh      |   1 +
 6 files changed, 204 insertions(+), 251 deletions(-)