git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] notes: avoid leaking duplicate entries
@ 2019-08-25  5:18 Mike Hommey
  2019-08-25  7:10 ` Jeff King
  2019-08-26  1:55 ` [PATCH] notes: avoid leaking duplicate entries Mike Hommey
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Hommey @ 2019-08-25  5:18 UTC (permalink / raw)
  To: git; +Cc: gitster

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-26  1:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-25  5:18 [PATCH] notes: avoid leaking duplicate entries Mike Hommey
2019-08-25  7:10 ` Jeff King
2019-08-25  7:19   ` [PATCH] notes: avoid potential use-after-free during insertion Jeff King
2019-08-26  1:55 ` [PATCH] notes: avoid leaking duplicate entries Mike Hommey

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).