Commit 92dc95a8ef154c5ab569feff59be53cea26f5a90

Stefan Sperling 2020-03-24T14:07:59

always initialize pack hash output parameter of got_fetch_pack()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/lib/fetch.c b/lib/fetch.c
index 9cdf678..ffdb2f2 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -418,6 +418,8 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
 	char *path;
 	char *progress = NULL;
 
+	*pack_hash = NULL;
+
 	/*
 	 * Prevent fetching of references that won't make any
 	 * sense outside of the remote repository's context.
@@ -434,7 +436,6 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
 	if (!list_refs_only)
 		repo_path = got_repo_get_path_git_dir(repo);
 
-	*pack_hash = NULL;
 	for (i = 0; i < nitems(tmpfds); i++)
 		tmpfds[i] = -1;