]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl_global_init_mem: set function pointers before doing init
authorDaniel Stenberg <daniel@haxx.se>
Fri, 9 Oct 2015 14:04:11 +0000 (16:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 9 Oct 2015 14:04:11 +0000 (16:04 +0200)
... as in the polarssl TLS backend for example it uses memory functions.

lib/easy.c

index 316acb1d18681bda33b9543c94b98f9c8c53086d..8b1fc03712a12bfc5e2927c17bb568edd971ee09 100644 (file)
@@ -292,8 +292,6 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
                               curl_free_callback f, curl_realloc_callback r,
                               curl_strdup_callback s, curl_calloc_callback c)
 {
-  CURLcode result = CURLE_OK;
-
   /* Invalid input, return immediately */
   if(!m || !f || !r || !s || !c)
     return CURLE_FAILED_INIT;
@@ -306,17 +304,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
     return CURLE_OK;
   }
 
-  /* Call the actual init function first */
-  result = curl_global_init(flags);
-  if(!result) {
-    Curl_cmalloc = m;
-    Curl_cfree = f;
-    Curl_cstrdup = s;
-    Curl_crealloc = r;
-    Curl_ccalloc = c;
-  }
+  /* set memory functions before global_init() in case it wants memory
+     functions */
+  Curl_cmalloc = m;
+  Curl_cfree = f;
+  Curl_cstrdup = s;
+  Curl_crealloc = r;
+  Curl_ccalloc = c;
 
-  return result;
+  /* Call the actual init function */
+  return curl_global_init(flags);
 }
 
 /**