Skip to content

Commit

Permalink
curl_global_init_mem: set function pointers before doing init
Browse files Browse the repository at this point in the history
... as in the polarssl TLS backend for example it uses memory functions.
  • Loading branch information
bagder committed Oct 9, 2015
1 parent 048f846 commit 6f8ecea
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/easy.c
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 6f8ecea

Please sign in to comment.