]> git.99rst.org Git - git.git/commit
merge-ort: free diff pairs queue in clear_or_reinit_internal_opts()
authorElijah Newren <redacted>
Sun, 14 Jun 2026 06:37:24 +0000 (06:37 +0000)
committerJunio C Hamano <redacted>
Sun, 14 Jun 2026 14:50:47 +0000 (07:50 -0700)
commit83ae606c9838b06bde36479756de2ab75b6fbb96
treeb6180431c7bec80a1d13e84fc84fa83e63dc334d
parent159e4d903458ac3ec0aa944aefeadbaf9e83b73c
merge-ort: free diff pairs queue in clear_or_reinit_internal_opts()

clear_or_reinit_internal_opts() is responsible for cleaning up the
various data structures in merge_options_internal.  It already handles
many renames-related structures (dirs_removed, dir_renames,
relevant_sources, cached_pairs, deferred, etc.) but does not free
renames->pairs[].queue.

In the normal code path, resolve_and_process_renames() frees
pairs[s].queue and reinitializes it with diff_queue_init() before
clear_or_reinit_internal_opts() runs, so the omission is harmless.
However, if collect_merge_info() encounters an error and returns early
(before resolve_and_process_renames() is ever called), any diff pairs
already queued by collect_rename_info()/add_pair() will have their
backing array leaked.

Fix this by freeing renames->pairs[].queue in the cleanup function.
In the normal path the pointer is already NULL (from the earlier
diff_queue_init() in resolve_and_process_renames()), so free(NULL) is
a safe no-op.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
merge-ort.c
git clone https://git.99rst.org/PROJECT