Commit Diff


commit - 5ddd7ddb3ce581cbbd07e4e5e88839c05e2a62b1
commit + c450903bc2ce2dadb398b935473a6e355894e243
blob - 02b0eae943c002b268adbb1836eda2ac7816e499
blob + f03b63655d11f0912e5c2dd4b182296979de8e36
--- lib/fetch.c
+++ lib/fetch.c
@@ -313,9 +313,11 @@ got_fetch_pack(struct got_object_id **pack_hash, struc
 		if (packfile_size_cur <= ssizeof(pack_hdr) + SHA1_DIGEST_LENGTH)
 			packfile_size_cur = 0;
 		if (!done && refname && id) {
-			err = got_pathlist_insert(NULL, refs, refname, id);
+			err = got_pathlist_insert(&pe, refs, refname, id);
 			if (err)
 				goto done;
+			if (pe == NULL)
+				free(id);
 		} else if (!done && server_progress) {
 			char *p;
 			/*
blob - 572f79cfc16c871370788135675712401d386ddf
blob + 8ec7b9fb1ba48a9fa452a728bb1787df461ef284
--- lib/send.c
+++ lib/send.c
@@ -172,6 +172,7 @@ insert_sendable_ref(struct got_pathlist_head *refs, co
 	const struct got_error *err;
 	struct got_reference *ref;
 	struct got_object_id *id = NULL;
+	struct got_pathlist_entry *new = NULL;
 	int obj_type;
 
 	err = got_ref_open(&ref, repo, refname, 0);
@@ -200,11 +201,11 @@ insert_sendable_ref(struct got_pathlist_head *refs, co
 		goto done;
 	}
 
-	err = got_pathlist_insert(NULL, refs, target_refname, id);
+	err = got_pathlist_insert(&new, refs, target_refname, id);
 done:
 	if (ref)
 		got_ref_close(ref);
-	if (err)
+	if (err || new == NULL /* duplicate */)
 		free(id);
 	return err;
 }