When add_note is called multiple times with the same key/value pair, the leaf_node it creates is leaked by notes_tree_insert. --- notes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notes.c b/notes.c index 75c028b300..ec35f5b551 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); -- 2.23.0