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 <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mike Hommey committed
Aug 25, 2019 at 14:18 UTC
779ad6641b9a6443eaec75439b3374b1a7b8794c
1 file changed
+3
-1
notes.c
+3
-1
@@ -269,8 +269,10 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
269
case PTR_TYPE_NOTE:
270
if (oideq(&l->key_oid, &entry->key_oid)) {
271
/* skip concatenation if l == entry */
272
- if (oideq(&l->val_oid, &entry->val_oid))
272
+ if (oideq(&l->val_oid, &entry->val_oid)) {
273
+ free(entry);
274
return 0;
275
+ }
276
277
ret = combine_notes(&l->val_oid,
278
&entry->val_oid);