Skip to content

Commit c718f36

Browse files
committed
revisions & diff API: add an "is_dead"
Add an "is_dead" member to "struct diff_options" and "struct rev_info" as a marker for the diff_free() and release_revisions() functions already having been run on them. This will help to ensure that subsequent changes won't introduce the sort of issues resolved in 5cdb384 (2.36 show regression fix, 2022-04-29) and 91f8f7e (2.36 format-patch regression fix, 2022-04-30). See https://lore.kernel.org/git/6af1aed1-ab13-ee0e-e979-d2f826ec776a@web.de for the initial suggestion to do this. Suggested-by: René Scharfe <l.s.r@web.de> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
1 parent 2c9bf36 commit c718f36

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

diff.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6507,10 +6507,14 @@ static void diff_free_ignore_regex(struct diff_options *options)
65076507

65086508
void diff_free(struct diff_options *options)
65096509
{
6510+
if (options->is_dead)
6511+
BUG("double diff_free() on %p", (void *)options);
6512+
65106513
diff_free_file(options);
65116514
diff_free_ignore_regex(options);
65126515
clear_pathspec(&options->pathspec);
65136516
FREE_AND_NULL(options->parseopts);
6517+
options->is_dead = 1;
65146518
}
65156519

65166520
void diff_flush(struct diff_options *options)

diff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ struct diff_options {
388388
struct repository *repo;
389389
struct option *parseopts;
390390
struct strmap *additional_path_headers;
391+
392+
int is_dead;
391393
};
392394

393395
unsigned diff_filter_bit(char status);

revision.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,9 @@ static void release_revisions_topo_walk_info(struct topo_walk_info *info);
30103010

30113011
void release_revisions(struct rev_info *revs)
30123012
{
3013+
if (revs->is_dead)
3014+
BUG("double release_revisions() on %p", (void *)revs);
3015+
30133016
free_commit_list(revs->commits);
30143017
free_commit_list(revs->ancestry_path_bottoms);
30153018
object_array_clear(&revs->pending);

revision.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ struct rev_info {
338338

339339
/* Location where temporary objects for remerge-diff are written. */
340340
struct tmp_objdir *remerge_objdir;
341+
342+
int is_dead;
341343
};
342344

343345
/**

0 commit comments

Comments
 (0)