Commit 27a1ed032f37a6bf70d5bdabd452600125aa7d18

Stefan Sperling 2019-03-15T12:59:35

don't leak 'new' in insert_ref()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/reference.c b/lib/reference.c
index 739dc46..a5ab53c 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -574,9 +574,11 @@ insert_ref(struct got_reflist_head *refs, struct got_reference *ref,
 	re = SIMPLEQ_FIRST(refs);
 	while (re) {
 		cmp = got_path_cmp(got_ref_get_name(re->ref),
-		    got_ref_get_name(ref));
+		    got_ref_get_name(new->ref));
 		if (cmp == 0) {
-			got_ref_close(ref); /* duplicate */
+			/* duplicate */
+			free(new->id);
+			free(new);
 			return NULL;
 		} else if (cmp > 0) {
 			if (prev)