summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-09-30 04:19:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-09-30 04:19:25 (GMT)
commit74a39b9bcc9086cf4405aa532bb6e02e3436d5e4 (patch)
tree80d32ddef577b66630c76ae215167358b25d9a41 /notes.c
parent37801f0665623e354e91ddd9c0bd5a2a4530fa24 (diff)
parent60fe477a0be2a3801e5ce3913e0be8e8e2e58e4f (diff)
downloadgit-74a39b9bcc9086cf4405aa532bb6e02e3436d5e4.zip
git-74a39b9bcc9086cf4405aa532bb6e02e3436d5e4.tar.gz
git-74a39b9bcc9086cf4405aa532bb6e02e3436d5e4.tar.bz2
Merge branch 'mh/notes-duplicate-entries'
A few implementation fixes in the notes API. * mh/notes-duplicate-entries: notes: avoid potential use-after-free during insertion notes: avoid leaking duplicate entries
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/notes.c b/notes.c
index 75c028b..03e7d0c 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);
@@ -458,7 +460,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
die("Failed to load %s %s into notes tree "
"from %s",
type == PTR_TYPE_NOTE ? "note" : "subtree",
- oid_to_hex(&l->key_oid), t->ref);
+ oid_to_hex(&object_oid), t->ref);
continue;