Skip to content

Commit 74a39b9

Browse files
committed
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
2 parents 37801f0 + 60fe477 commit 74a39b9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

notes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,10 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
269269
case PTR_TYPE_NOTE:
270270
if (oideq(&l->key_oid, &entry->key_oid)) {
271271
/* 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);
273274
return 0;
275+
}
274276

275277
ret = combine_notes(&l->val_oid,
276278
&entry->val_oid);
@@ -458,7 +460,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
458460
die("Failed to load %s %s into notes tree "
459461
"from %s",
460462
type == PTR_TYPE_NOTE ? "note" : "subtree",
461-
oid_to_hex(&l->key_oid), t->ref);
463+
oid_to_hex(&object_oid), t->ref);
462464

463465
continue;
464466

0 commit comments

Comments
 (0)