summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-11-28 16:21:58 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-11-28 16:21:58 +0100
commitfdb432e67f785698946d1d5e66b29de6cb79422d (patch)
tree5b515af01bee0c84ea9d7fa23a41f9d73485fb74
parentbb8cf0516953eea24cdedee47d31db77e8ced0dc (diff)
downloadcurl-bagder/global_init-init2.tar.gz
global_init: undo the "intialized" bump in case of failurebagder/global_init-init2
... so that failures in the global init function don't count as a working init and it can then be called again. Reported-by: Paul Groke Fixes #4636
-rw-r--r--lib/easy.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/easy.c b/lib/easy.c
index 1d02c0cc1..6382cee3d 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -157,20 +157,20 @@ static CURLcode global_init(long flags, bool memoryfuncs)
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
- return CURLE_FAILED_INIT;
+ goto fail;
}
#ifdef WIN32
if(Curl_win32_init(flags)) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
- return CURLE_FAILED_INIT;
+ goto fail;
}
#endif
#ifdef __AMIGA__
if(!Curl_amiga_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_amiga_init failed\n"));
- return CURLE_FAILED_INIT;
+ goto fail;
}
#endif
@@ -182,14 +182,14 @@ static CURLcode global_init(long flags, bool memoryfuncs)
if(Curl_resolver_global_init()) {
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
- return CURLE_FAILED_INIT;
+ goto fail;
}
(void)Curl_ipv6works();
#if defined(USE_SSH)
if(Curl_ssh_init()) {
- return CURLE_FAILED_INIT;
+ goto fail;
}
#endif
@@ -201,6 +201,10 @@ static CURLcode global_init(long flags, bool memoryfuncs)
Curl_version_init();
return CURLE_OK;
+
+ fail:
+ initialized--; /* undo the increase */
+ return CURLE_FAILED_INIT;
}