aboutsummaryrefslogtreecommitdiffstats
path: root/commit.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-22 11:17:33 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-22 09:18:04 -0700
commit8a7846383e80ad3370344d752c5bb3a2c78cbf65 (patch)
tree6d1f504cf5fdbedd3e525a6bea8fe7262aad8e87 /commit.c
parentbuiltin/archive: fix leaking `OPT_FILENAME()` value (diff)
downloadgit-8a7846383e80ad3370344d752c5bb3a2c78cbf65.tar.gz
git-8a7846383e80ad3370344d752c5bb3a2c78cbf65.zip
midx-write: fix leaking hashfile on error cases
When writing the MIDX file we first create the `struct hashfile` used to write the trailer hash, and then afterwards we verify whether we can actually write the MIDX in the first place. When we decide that we can't, this leads to a memory leak because we never free the hash file contents. We could fix this by freeing the hashfile on the exit path. There is a better option though: we can simply move the checks for the error condition earlier. As there is no early exit between creating the hashfile and finalizing it anymore this is sufficient to fix the memory leak. While at it, also move around the block checking for `ctx.entries_nr`. This change is not required to fix the memory leak, but it feels natural to move together all massaging of parameters before we go with them and execute the actual logic. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
0 files changed, 0 insertions, 0 deletions