Thread (24 messages) 24 messages, 3 authors, 2019-10-08
STALE2460d REVIEWED: 1 (0M)
Revisions (2)
  1. v2 [diff vs current]
  2. v3 current

[PATCH v3 01/20] diff: use hashmap_entry_init on moved_entry.ent

From: Eric Wong <hidden>
Date: 2019-10-06 23:30:48
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Reviewed-by: Derrick Stolee <redacted>
---
 diff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index efe42b341a..02491ee684 100644
--- a/diff.c
+++ b/diff.c
@@ -964,8 +964,9 @@ static struct moved_entry *prepare_entry(struct diff_options *o,
 	struct moved_entry *ret = xmalloc(sizeof(*ret));
 	struct emitted_diff_symbol *l = &o->emitted_symbols->buf[line_no];
 	unsigned flags = o->color_moved_ws_handling & XDF_WHITESPACE_FLAGS;
+	unsigned int hash = xdiff_hash_string(l->line, l->len, flags);
 
-	ret->ent.hash = xdiff_hash_string(l->line, l->len, flags);
+	hashmap_entry_init(&ret->ent, hash);
 	ret->es = l;
 	ret->next_line = NULL;
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help