git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] notes: avoid leaking duplicate entries

From
Mike Hommey <mh@glandium.org>
Date
Aug 25, 2019, 05:18 UTC
Message-ID
<20190825051818.9621-1-mh@glandium.org>
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
Next: Jeff King
Message 1 of 4 in “notes: avoid leaking duplicate entries”
  1. notes: avoid leaking duplicate entriesMike Hommey, Aug 25, 2019
  2. Jeff KingAug 25, 2019
  3. notes: avoid potential use-after-free during insertionJeff King, Aug 25, 2019
  4. Mike HommeyAug 26, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.