Commit 2fe887e6fac269332a5ba6c7f7aa99acaa403c9d

Etienne Samson 2018-04-18T20:57:16

remote: repo is optional here As per CID:1378747, we might be called with a NULL repo, which would be deferenced in write_add_refspec

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/remote.c b/src/remote.c
index 4d675af..d8a6b99 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -237,7 +237,7 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
 			goto on_error;
 
 		/* only write for non-anonymous remotes */
-		if (name && (error = write_add_refspec(repo, name, fetch, true)) < 0)
+		if (repo && name && (error = write_add_refspec(repo, name, fetch, true)) < 0)
 			goto on_error;
 
 		if (repo && (error = lookup_remote_prune_config(remote, config_ro, name)) < 0)