summaryrefslogtreecommitdiff
path: root/t/helper/test-submodule-nested-repo-config.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-11-05 07:17:28 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-04 22:37:55 -0800
commit1981d1eb3ecdefd2cdc665184d366728721f76e5 (patch)
tree3c51f54546f0f42b7ba0cf9368e8a97c005798e5 /t/helper/test-submodule-nested-repo-config.c
parentd06e3ec858d4863baa5f918db414e890b08891d7 (diff)
combine-diff: fix leaking lost lines
The `cnt` variable tracks the number of lines in a patch diff. It can happen though that there are no newlines, in which case we'd still end up allocating our array of `sline`s. In fact, we always allocate it with `cnt + 2` entries: one extra entry for the deletion hunk at the end, and another entry that we don't seem to ever populate at all but acts as a kind of sentinel value. When we loop through the array to clear it at the end of this function we only loop until `lno < cnt`, and thus we may not end up releasing whatever the two extra `sline`s contain. While that shouldn't matter for the sentinel value, it does matter for the extra deletion hunk sline. Regardless of that, plug this memory leak by releasing both extra entries, which makes the logic a bit easier to reason about. While at it, fix the formatting of a local comment, which incidentally also provides the necessary context for why we overallocate the `sline` array. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-submodule-nested-repo-config.c')
0 files changed, 0 insertions, 0 deletions