Skip to content

Commit e010a41

Browse files
Eric Wonggitster
authored andcommitted
diff: use hashmap_entry_init on moved_entry.ent
Otherwise, the hashmap_entry.next field appears to remain uninitialized, which can lead to problems when add_lines_to_move_detection calls hashmap_add. I found this through manual inspection when converting hashmap_add callers to take "struct hashmap_entry *". Signed-off-by: Eric Wong <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 745f681 commit e010a41

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,9 @@ static struct moved_entry *prepare_entry(struct diff_options *o,
964964
struct moved_entry *ret = xmalloc(sizeof(*ret));
965965
struct emitted_diff_symbol *l = &o->emitted_symbols->buf[line_no];
966966
unsigned flags = o->color_moved_ws_handling & XDF_WHITESPACE_FLAGS;
967+
unsigned int hash = xdiff_hash_string(l->line, l->len, flags);
967968

968-
ret->ent.hash = xdiff_hash_string(l->line, l->len, flags);
969+
hashmap_entry_init(&ret->ent, hash);
969970
ret->es = l;
970971
ret->next_line = NULL;
971972

0 commit comments

Comments
 (0)