Skip to content

Commit eec7f53

Browse files
phillipwoodgitster
authored andcommitted
diff --color-moved: stop clearing potential moved blocks
moved_block_clear() was introduced in 74d156f ("diff --color-moved-ws: fix double free crash", 2018-10-04) to free the memory that was allocated when initializing a potential moved block. However since 21536d0 ("diff --color-moved-ws: modify allow-indentation-change", 2018-11-23) initializing a potential moved block no longer allocates any memory. Up until the last commit we were relying on moved_block_clear() to set the `match` pointer to NULL when a block stopped matching, but since that commit we do not clear a moved block that does not match so it does not make sense to clear them elsewhere. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e488f1 commit eec7f53

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

diff.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,6 @@ struct moved_block {
807807
int wsd; /* The whitespace delta of this block */
808808
};
809809

810-
static void moved_block_clear(struct moved_block *b)
811-
{
812-
memset(b, 0, sizeof(*b));
813-
}
814-
815810
#define INDENT_BLANKLINE INT_MIN
816811

817812
static void fill_es_indent_data(struct emitted_diff_symbol *es)
@@ -1128,8 +1123,6 @@ static void mark_color_as_moved(struct diff_options *o,
11281123
}
11291124

11301125
if (pmb_nr && (!match || l->s != moved_symbol)) {
1131-
int i;
1132-
11331126
if (!adjust_last_block(o, n, block_length) &&
11341127
block_length > 1) {
11351128
/*
@@ -1139,8 +1132,6 @@ static void mark_color_as_moved(struct diff_options *o,
11391132
match = NULL;
11401133
n -= block_length;
11411134
}
1142-
for(i = 0; i < pmb_nr; i++)
1143-
moved_block_clear(&pmb[i]);
11441135
pmb_nr = 0;
11451136
block_length = 0;
11461137
flipped_block = 0;
@@ -1193,8 +1184,6 @@ static void mark_color_as_moved(struct diff_options *o,
11931184
}
11941185
adjust_last_block(o, n, block_length);
11951186

1196-
for(n = 0; n < pmb_nr; n++)
1197-
moved_block_clear(&pmb[n]);
11981187
free(pmb);
11991188
}
12001189

0 commit comments

Comments
 (0)