Skip to content

Commit 6ee3636

Browse files
avargitster
authored andcommitted
diff.[ch]: have diff_free() free options->parseopts
The "struct option" added in 4a28847 (diff.c: prepare to use parse_options() for parsing, 2019-01-27) would be free'd in the case of diff_setup_done() being called. But not all codepaths that allocate it reach that, e.g. "t6427-diff3-conflict-markers.sh" will now free memory that it didn't free before. By using FREE_AND_NULL() here (which diff_setup_done() also does) we ensure that we free the memory, and that we won't have double-free's. Before this running: ./t6427-diff3-conflict-markers.sh -vixd --run=7 Would report: SUMMARY: LeakSanitizer: 7823 byte(s) leaked in 6 allocation(s). But now we'll report: SUMMARY: LeakSanitizer: 703 byte(s) leaked in 5 allocation(s). I.e. the largest leak in that particular test has now been addressed. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 244c272 commit 6ee3636

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6346,6 +6346,7 @@ void diff_free(struct diff_options *options)
63466346
diff_free_file(options);
63476347
diff_free_ignore_regex(options);
63486348
clear_pathspec(&options->pathspec);
6349+
FREE_AND_NULL(options->parseopts);
63496350
}
63506351

63516352
void diff_flush(struct diff_options *options)

0 commit comments

Comments
 (0)