mirror of
https://github.com/curl/curl.git
synced 2026-08-24 13:43:32 +03:00
curlx: limit use of system allocators to the minimum possible
Clone a multibye conversion function into curlx/fopen, and use that local copy from curlx/fopen functions. Adjust allocators in curlx/fopen to use curl's in normal builds, and system allocators in TrackMemory builds to avoid recursion. This allows to switch curlx/multibyte functions to curl allocators in all configurations, as they are no longer called by curlx/fopen, and a recursive call can no longer happen. After this patch the system allocator is only used in TrackMemory Windows builds, within curlx `fopen`, `freopen`, `stat` and `open` functions. Also: - test 1, 440, 767: raise allocation limitsto fit the extra allocations in Windows Unicode builds. - replace all uses of `curlx_unicodefree()` macro with `curlx_free()` across the codebase. - curlx/multibyte: delete `curlx_unicodefree()`. - ldap: join Windows and non-Windows codepaths that became identical after moving from `curlx_unicodefree()` to `curlx_free()`. - vauth: drop a strdup from standard to curl allocator since the original allocation is now already done by curl's. - tool_doswin: drop now superfluous strdup from `FindWin32CACert()`. - memanalyzer.pm: sync weirdo `calloc` log message with `malloc`'s. Fixes #19748 Closes #19845
This commit is contained in:
parent
2d6ade19fc
commit
4e051ff550
19 changed files with 100 additions and 113 deletions
|
|
@ -273,7 +273,7 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg,
|
|||
|
||||
dup_domain.tchar_ptr = curlx_tcsdup(domain.tchar_ptr);
|
||||
if(!dup_domain.tchar_ptr) {
|
||||
curlx_unicodefree(domain.tchar_ptr);
|
||||
curlx_free(domain.tchar_ptr);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg,
|
|||
identity->DomainLength = curlx_uztoul(_tcslen(dup_domain.tchar_ptr));
|
||||
dup_domain.tchar_ptr = NULL;
|
||||
|
||||
curlx_unicodefree(domain.tchar_ptr);
|
||||
curlx_free(domain.tchar_ptr);
|
||||
}
|
||||
else {
|
||||
/* Unknown specifier, ignore it! */
|
||||
|
|
@ -579,7 +579,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
|
|||
digest->http_context = curlx_calloc(1, sizeof(CtxtHandle));
|
||||
if(!digest->http_context) {
|
||||
Curl_pSecFn->FreeCredentialsHandle(&credentials);
|
||||
curlx_unicodefree(spn);
|
||||
curlx_free(spn);
|
||||
Curl_sspi_free_identity(p_identity);
|
||||
curlx_free(output_token);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -592,7 +592,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
|
|||
&chlg_desc, 0,
|
||||
digest->http_context,
|
||||
&resp_desc, &attrs, NULL);
|
||||
curlx_unicodefree(spn);
|
||||
curlx_free(spn);
|
||||
|
||||
if(status == SEC_I_COMPLETE_NEEDED ||
|
||||
status == SEC_I_COMPLETE_AND_CONTINUE)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host,
|
|||
{
|
||||
char *utf8_spn = NULL;
|
||||
TCHAR *tchar_spn = NULL;
|
||||
TCHAR *dupe_tchar_spn = NULL;
|
||||
|
||||
(void)realm;
|
||||
|
||||
|
|
@ -87,16 +86,11 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host,
|
|||
if(!utf8_spn)
|
||||
return NULL;
|
||||
|
||||
/* Allocate and return a TCHAR based SPN. Since curlx_convert_UTF8_to_tchar
|
||||
must be freed by curlx_unicodefree we will dupe the result so that the
|
||||
pointer this function returns can be normally free'd. */
|
||||
/* Allocate and return a TCHAR based SPN. */
|
||||
tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn);
|
||||
curlx_free(utf8_spn);
|
||||
if(!tchar_spn)
|
||||
return NULL;
|
||||
dupe_tchar_spn = curlx_tcsdup(tchar_spn);
|
||||
curlx_unicodefree(tchar_spn);
|
||||
return dupe_tchar_spn;
|
||||
|
||||
return tchar_spn;
|
||||
}
|
||||
#endif /* USE_WINDOWS_SSPI */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue