Commit 5b08a71fcbfa784bded6e753508501fae870a612

Edward Thomson 2019-01-14T21:00:42

Merge pull request #4934 from stinb/proxy-crash Fix crash on remote connection when GIT_PROXY_AUTO is set but no proxy is detected

diff --git a/src/transports/http.c b/src/transports/http.c
index 3a0d2cc..387754e 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -679,6 +679,9 @@ static int load_proxy_config(http_subtransport *t)
 		    !!t->server.url.use_ssl, &t->proxy_url)) < 0)
 			return error;
 
+		if (!t->proxy_url)
+			return 0;
+
 		t->proxy_opts.type = GIT_PROXY_SPECIFIED;
 		t->proxy_opts.url = t->proxy_url;
 		t->proxy_opts.credentials = t->owner->proxy.credentials;
diff --git a/tests/online/clone.c b/tests/online/clone.c
index ce49f18..928b7bc 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -840,3 +840,10 @@ void test_online_clone__proxy_credentials_in_environment(void)
 
 	git_buf_dispose(&url);
 }
+
+void test_online_clone__proxy_auto_not_detected(void)
+{
+	g_options.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO;
+
+	cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
+}