commit-graph: fix memory leak when not writing graph
commit4efa9308eabba5b474f7ff5b43a8a7b767b6de79
authorPatrick Steinhardt <ps@pks.im>
Mon, 18 Dec 2023 10:02:28 +0000 (18 11:02 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jan 2024 01:08:28 +0000 (15 17:08 -0800)
treecd96a9971439ec31e0feff6957014d7aa95fed44
parentd4dbce1db5cd227a57074bcfc7ec9f0655961bba
commit-graph: fix memory leak when not writing graph

When `write_commit_graph()` bails out writing a split commit-graph early
then it may happen that we have already gathered the set of existing
commit-graph file names without yet determining the new merged set of
files. This can result in a memory leak though because we only clear the
preimage of files when we have collected the postimage.

Fix this issue by dropping the condition altogether so that we always
try to free both preimage and postimage filenames. As the context
structure is zero-initialized this simplification is safe to do.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c