From: Mike Hommey Date: Sun, 25 Aug 2019 05:18:18 +0000 (+0900) Subject: notes: avoid leaking duplicate entries X-Git-Tag: v2.24.0-rc0~118^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=779ad6641b9a6443eaec75439b3374b1a7b8794c;p=git notes: avoid leaking duplicate entries When add_note is called multiple times with the same key/value pair, the leaf_node it creates is leaked by notes_tree_insert. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- diff --git a/notes.c b/notes.c index 532ec37865..3130add618 100644 --- a/notes.c +++ b/notes.c @@ -269,8 +269,10 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree, case PTR_TYPE_NOTE: if (oideq(&l->key_oid, &entry->key_oid)) { /* skip concatenation if l == entry */ - if (oideq(&l->val_oid, &entry->val_oid)) + if (oideq(&l->val_oid, &entry->val_oid)) { + free(entry); return 0; + } ret = combine_notes(&l->val_oid, &entry->val_oid);