Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2019-08-25 08:18:18 +0300
committerJunio C Hamano <gitster@pobox.com>2019-08-26 20:29:38 +0300
commit779ad6641b9a6443eaec75439b3374b1a7b8794c (patch)
treee1ce9a7d64df97bd2cf0d4de9ad1bc854054079e /notes.c
parent75b2f01a0f642b39b0f29b6218515df9b5eb798e (diff)
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>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c4
1 files changed, 3 insertions, 1 deletions
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);