Commit df4937b83e96c008cddf001b361ddf5626e68c6d

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)