Skip to content

Commit 6c1d42a

Browse files
committed
Merge branch 'br/http-init-fix'
Code clean-up. * br/http-init-fix: http: style fixes for curl_multi_init error check http.c: die if curl_*_init fails
2 parents 825fd93 + 8837eb4 commit 6c1d42a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

http.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ static CURL *get_curl_handle(void)
300300
{
301301
CURL *result = curl_easy_init();
302302

303+
if (!result)
304+
die("curl_easy_init failed");
305+
303306
if (!curl_ssl_verify) {
304307
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
305308
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);
@@ -399,7 +402,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
399402
git_config(urlmatch_config_entry, &config);
400403
free(normalized_url);
401404

402-
curl_global_init(CURL_GLOBAL_ALL);
405+
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
406+
die("curl_global_init failed");
403407

404408
http_proactive_auth = proactive_auth;
405409

@@ -417,10 +421,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
417421
}
418422

419423
curlm = curl_multi_init();
420-
if (curlm == NULL) {
421-
fprintf(stderr, "Error creating curl multi handle.\n");
422-
exit(1);
423-
}
424+
if (!curlm)
425+
die("curl_multi_init failed");
424426
#endif
425427

426428
if (getenv("GIT_SSL_NO_VERIFY"))

0 commit comments

Comments
 (0)