]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/fast-export: fix leaking diff options
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:26 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:07:59 +0000 (10:07 -0700)
Before calling `handle_commit()` in a loop, we set `diffopt.no_free`
such that its contents aren't getting freed inside of `handle_commit()`.
We never unset that flag though, which means that the structure's
allocated resources will ultimately leak.

Fix this by unsetting the flag after the loop such that we release its
resources via `release_revisions()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c

index 4b6e8c6832b84123003322995dcff1452a25bd17..fe92d2436cf1b1b7ce470b3409f0e958d388ae00 100644 (file)
@@ -1278,9 +1278,11 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
        revs.diffopt.format_callback = show_filemodify;
        revs.diffopt.format_callback_data = &paths_of_changed_objects;
        revs.diffopt.flags.recursive = 1;
+
        revs.diffopt.no_free = 1;
        while ((commit = get_revision(&revs)))
                handle_commit(commit, &revs, &paths_of_changed_objects);
+       revs.diffopt.no_free = 0;
 
        handle_tags_and_duplicates(&extra_refs);
        handle_tags_and_duplicates(&tag_refs);