]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curlx: limit use of system allocators to the minimum possible
authorViktor Szakats <commit@vsz.me>
Thu, 4 Dec 2025 22:54:25 +0000 (23:54 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 5 Dec 2025 14:32:59 +0000 (15:32 +0100)
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

19 files changed:
lib/curl_sspi.c
lib/curlx/curlx.h
lib/curlx/fopen.c
lib/curlx/multibyte.c
lib/curlx/multibyte.h
lib/ldap.c
lib/rename.c
lib/socks_sspi.c
lib/vauth/digest_sspi.c
lib/vauth/vauth.c
lib/vtls/schannel.c
lib/vtls/schannel_verify.c
src/tool_doswin.c
src/tool_filetime.c
src/tool_getparam.h
tests/data/test1
tests/data/test440
tests/data/test767
tests/memanalyzer.pm

index 264703d8cd703dfe9ba62e1cda2c338dd18377b4..712fab2e9e823a6703f32699e0f169326b870ecd 100644 (file)
@@ -132,7 +132,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
   /* Setup the identity's user and length */
   dup_user.tchar_ptr = curlx_tcsdup(user.tchar_ptr);
   if(!dup_user.tchar_ptr) {
-    curlx_unicodefree(useranddomain.tchar_ptr);
+    curlx_free(useranddomain.tchar_ptr);
     return CURLE_OUT_OF_MEMORY;
   }
   identity->User = dup_user.tbyte_ptr;
@@ -142,19 +142,19 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
   /* Setup the identity's domain and length */
   dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1));
   if(!dup_domain.tchar_ptr) {
-    curlx_unicodefree(useranddomain.tchar_ptr);
+    curlx_free(useranddomain.tchar_ptr);
     return CURLE_OUT_OF_MEMORY;
   }
   if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) {
-    curlx_unicodefree(dup_domain.tchar_ptr);
-    curlx_unicodefree(useranddomain.tchar_ptr);
+    curlx_free(dup_domain.tchar_ptr);
+    curlx_free(useranddomain.tchar_ptr);
     return CURLE_OUT_OF_MEMORY;
   }
   identity->Domain = dup_domain.tbyte_ptr;
   identity->DomainLength = curlx_uztoul(domlen);
   dup_domain.tchar_ptr = NULL;
 
-  curlx_unicodefree(useranddomain.tchar_ptr);
+  curlx_free(useranddomain.tchar_ptr);
 
   /* Setup the identity's password and length */
   passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp);
@@ -162,14 +162,14 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
     return CURLE_OUT_OF_MEMORY;
   dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr);
   if(!dup_passwd.tchar_ptr) {
-    curlx_unicodefree(passwd.tchar_ptr);
+    curlx_free(passwd.tchar_ptr);
     return CURLE_OUT_OF_MEMORY;
   }
   identity->Password = dup_passwd.tbyte_ptr;
   identity->PasswordLength = curlx_uztoul(_tcslen(dup_passwd.tchar_ptr));
   dup_passwd.tchar_ptr = NULL;
 
-  curlx_unicodefree(passwd.tchar_ptr);
+  curlx_free(passwd.tchar_ptr);
 
   /* Setup the identity's flags */
   identity->Flags = (unsigned long)
index 480e91950de00d1e5ffdabdb2e9e9b6a9e67670a..af46fae671d54a3b6c95c7fa1af287aa189d611b 100644 (file)
@@ -52,7 +52,6 @@
   curlx_convert_wchar_to_UTF8()
   curlx_convert_UTF8_to_tchar()
   curlx_convert_tchar_to_UTF8()
-  curlx_unicodefree()
 */
 
 #include "version_win32.h"
index 1838b7de8b8ca564e4db84dc2810765db9fcf1a4..c9b7a9c0b5900985c4b80f03b6c74650b3264476 100644 (file)
  *
  ***************************************************************************/
 
-/*
- * Use system allocators to avoid infinite recursion when called by curl's
- * memory tracker memdebug functions.
- */
-
 #include "../curl_setup.h"
 
 #include "fopen.h"
@@ -46,10 +41,43 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence)
 
 #ifdef _WIN32
 
-#include "multibyte.h"
-
 #include <share.h>  /* for _SH_DENYNO */
 
+#ifdef CURLDEBUG
+/*
+ * Use system allocators to avoid infinite recursion when called by curl's
+ * memory tracker memdebug functions.
+ */
+#define CURLX_MALLOC(x) malloc(x)
+#define CURLX_FREE(x)   free(x)
+#else
+#define CURLX_MALLOC(x) curlx_malloc(x)
+#define CURLX_FREE(x)   curlx_free(x)
+#endif
+
+#ifdef _UNICODE
+static wchar_t *fn_convert_UTF8_to_wchar(const char *str_utf8)
+{
+  wchar_t *str_w = NULL;
+
+  if(str_utf8) {
+    int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
+                                        str_utf8, -1, NULL, 0);
+    if(str_w_len > 0) {
+      str_w = CURLX_MALLOC(str_w_len * sizeof(wchar_t));
+      if(str_w) {
+        if(MultiByteToWideChar(CP_UTF8, 0,
+                               str_utf8, -1, str_w, str_w_len) == 0) {
+          CURLX_FREE(str_w);
+          return NULL;
+        }
+      }
+    }
+  }
+  return str_w;
+}
+#endif
+
 /* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */
 #if defined(CURL_WINDOWS_UWP) && defined(__MINGW32__) && \
   (_WIN32_WINNT < _WIN32_WINNT_WIN10)
@@ -228,7 +256,7 @@ int curlx_win32_open(const char *filename, int oflag, ...)
   const TCHAR *target = NULL;
 
 #ifdef _UNICODE
-  wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename);
+  wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename);
 #endif
 
   va_list param;
@@ -244,7 +272,7 @@ int curlx_win32_open(const char *filename, int oflag, ...)
     else
       target = filename_w;
     errno = _wsopen_s(&result, target, oflag, _SH_DENYNO, pmode);
-    curlx_unicodefree(filename_w);
+    CURLX_FREE(filename_w);
   }
   else
     /* !checksrc! disable ERRNOVAR 1 */
@@ -268,8 +296,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
   const TCHAR *target = NULL;
 
 #ifdef _UNICODE
-  wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename);
-  wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode);
+  wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename);
+  wchar_t *mode_w = fn_convert_UTF8_to_wchar(mode);
   if(filename_w && mode_w) {
     if(fix_excessive_path(filename_w, &fixed))
       target = fixed;
@@ -280,8 +308,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
   else
     /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
-  curlx_unicodefree(filename_w);
-  curlx_unicodefree(mode_w);
+  CURLX_FREE(filename_w);
+  CURLX_FREE(mode_w);
 #else
   if(fix_excessive_path(filename, &fixed))
     target = fixed;
@@ -306,8 +334,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp)
   const TCHAR *target = NULL;
 
 #ifdef _UNICODE
-  wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename);
-  wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode);
+  wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename);
+  wchar_t *mode_w = fn_convert_UTF8_to_wchar(mode);
   if(filename_w && mode_w) {
     if(fix_excessive_path(filename_w, &fixed))
       target = fixed;
@@ -318,8 +346,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp)
   else
     /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
-  curlx_unicodefree(filename_w);
-  curlx_unicodefree(mode_w);
+  CURLX_FREE(filename_w);
+  CURLX_FREE(mode_w);
 #else
   if(fix_excessive_path(filename, &fixed))
     target = fixed;
@@ -339,7 +367,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
   const TCHAR *target = NULL;
 
 #ifdef _UNICODE
-  wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
+  wchar_t *path_w = fn_convert_UTF8_to_wchar(path);
   if(path_w) {
     if(fix_excessive_path(path_w, &fixed))
       target = fixed;
@@ -350,7 +378,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
 #else
     result = _wstati64(target, buffer);
 #endif
-    curlx_unicodefree(path_w);
+    CURLX_FREE(path_w);
   }
   else
     /* !checksrc! disable ERRNOVAR 1 */
@@ -371,4 +399,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
   return result;
 }
 
+#undef CURLX_MALLOC
+#undef CURLX_FREE
+
 #endif /* _WIN32 */
index 3a33fcedfc65b91ba409522827cb0d9119f8a361..71170df2c549d884bc7d0973ac511c3899a0d24d 100644 (file)
  *
  ***************************************************************************/
 
-/*
- * Use system allocators to avoid infinite recursion when called by curl's
- * memory tracker memdebug functions.
- */
-
 #include "../curl_setup.h"
 
 #if defined(_WIN32) && defined(UNICODE)
@@ -45,11 +40,11 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8)
     int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
                                         str_utf8, -1, NULL, 0);
     if(str_w_len > 0) {
-      str_w = CURLX_MALLOC(str_w_len * sizeof(wchar_t));
+      str_w = curlx_malloc(str_w_len * sizeof(wchar_t));
       if(str_w) {
         if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
                                str_w_len) == 0) {
-          CURLX_FREE(str_w);
+          curlx_free(str_w);
           return NULL;
         }
       }
@@ -67,11 +62,11 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
     int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1,
                                     NULL, 0, NULL, NULL);
     if(bytes > 0) {
-      str_utf8 = CURLX_MALLOC(bytes);
+      str_utf8 = curlx_malloc(bytes);
       if(str_utf8) {
         if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
                                NULL, NULL) == 0) {
-          CURLX_FREE(str_utf8);
+          curlx_free(str_utf8);
           return NULL;
         }
       }
index fd264e180efa29365bc2127e4fa75523903c378e..8b19257222ca8f04b582a10116149a46803d9725 100644 (file)
 
 /*
  * Macros curlx_convert_UTF8_to_tchar(), curlx_convert_tchar_to_UTF8()
- * and curlx_unicodefree() main purpose is to minimize the number of
- * preprocessor conditional directives needed by code using these
- * to differentiate Unicode from non-Unicode builds.
+ * main purpose is to minimize the number of preprocessor conditional
+ * directives needed by code using these to differentiate Unicode from
+ * non-Unicode builds.
  *
  * In the case of a non-Unicode build the tchar strings are char strings that
  * are duplicated via strdup and remain in whatever the passed in encoding is,
  * which is assumed to be UTF-8 but may be other encoding. Therefore the
  * significance of the conversion functions is primarily for Unicode builds.
- *
- * Allocated memory should be free'd with curlx_unicodefree().
- *
- * Use system allocators to avoid infinite recursion when called by curl's
- * memory tracker memdebug functions.
  */
 
-#ifdef CURLDEBUG
-#define CURLX_MALLOC(x) malloc(x)
-#define CURLX_FREE(x)   free(x)
-#else
-#define CURLX_MALLOC(x) curlx_malloc(x)
-#define CURLX_FREE(x)   curlx_free(x)
-#endif
-
-/* the purpose of this macro is to free() without being traced by memdebug */
-#define curlx_unicodefree(ptr) CURLX_FREE(ptr)
-
 #ifdef UNICODE
 
 /* MultiByte conversions using Windows kernel32 library. */
@@ -73,13 +57,8 @@ typedef union {
 
 #else /* !UNICODE */
 
-#ifdef CURLDEBUG
-#define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr)
-#define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr)
-#else
 #define curlx_convert_UTF8_to_tchar(ptr) curlx_strdup(ptr)
 #define curlx_convert_tchar_to_UTF8(ptr) curlx_strdup(ptr)
-#endif
 
 typedef union {
   char                *tchar_ptr;
index 3dfbb330dc94b46740c66c818a3c62f4954226cb..ba9620b4b1859a7d990d35c1c601b2c9a893d0bd 100644 (file)
@@ -96,7 +96,7 @@
 #include "connect.h"
 
 #ifdef USE_WIN32_LDAP
-#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
+#define FREE_ON_WINLDAP(x) curlx_free(x)
 #define curl_ldap_num_t    ULONG
 #else
 #define FREE_ON_WINLDAP(x)
@@ -296,8 +296,8 @@ static ULONG ldap_win_bind(struct Curl_easy *data, LDAP *server,
 
     rc = ldap_simple_bind_s(server, inuser, inpass);
 
-    curlx_unicodefree(inuser);
-    curlx_unicodefree(inpass);
+    curlx_free(inuser);
+    curlx_free(inpass);
   }
 #ifdef USE_WINDOWS_SSPI
   else {
@@ -1000,22 +1000,13 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp)
   if(!ludp)
     return;
 
-#ifdef USE_WIN32_LDAP
-  curlx_unicodefree(ludp->lud_dn);
-  curlx_unicodefree(ludp->lud_filter);
-#else
   curlx_free(ludp->lud_dn);
   curlx_free(ludp->lud_filter);
-#endif
 
   if(ludp->lud_attrs) {
     size_t i;
     for(i = 0; i < ludp->lud_attrs_dups; i++) {
-#ifdef USE_WIN32_LDAP
-      curlx_unicodefree(ludp->lud_attrs[i]);
-#else
       curlx_free(ludp->lud_attrs[i]);
-#endif
     }
     curlx_free(ludp->lud_attrs);
   }
index d3f80422e64137ff37d8caaddec9bd3922265ce0..11cd680aa6ddc8da337e95c6f315f29746c9f165 100644 (file)
@@ -46,14 +46,14 @@ int Curl_rename(const char *oldpath, const char *newpath)
   for(;;) {
     timediff_t diff;
     if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) {
-      curlx_unicodefree(tchar_oldpath);
-      curlx_unicodefree(tchar_newpath);
+      curlx_free(tchar_oldpath);
+      curlx_free(tchar_newpath);
       break;
     }
     diff = curlx_timediff_ms(curlx_now(), start);
     if(diff < 0 || diff > max_wait_ms) {
-      curlx_unicodefree(tchar_oldpath);
-      curlx_unicodefree(tchar_newpath);
+      curlx_free(tchar_oldpath);
+      curlx_free(tchar_newpath);
       return 1;
     }
     Sleep(1);
index 17e875557eea4ce82181351d7360f244030c6bf4..84d530151c5558a34cd1dc6e14c7b531dda535f4 100644 (file)
@@ -175,7 +175,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
                                              &output_desc,
                                              &sspi_ret_flags, NULL);
 
-    curlx_unicodefree(sname);
+    curlx_free(sname);
 
     Curl_safefree(sspi_recv_token.pvBuffer);
     sspi_recv_token.cbBuffer = 0;
@@ -298,7 +298,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
     char *user_utf8 = curlx_convert_tchar_to_UTF8(names.sUserName);
     infof(data, "SOCKS5 server authenticated user %s with GSS-API.",
           (user_utf8 ? user_utf8 : "(unknown)"));
-    curlx_unicodefree(user_utf8);
+    curlx_free(user_utf8);
 #endif
     Curl_pSecFn->FreeContextBuffer(names.sUserName);
     names.sUserName = NULL;
index c92b53dcfc2247be2e6cace57f1bd3aa93f06d84..dc3afcc883571e1dd564a442f49410033a7fd5ea 100644 (file)
@@ -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)
index 9b87bd2c6757aec285f4e8bda7428bed25e02cdc..25924806f2b947f97bc9b4aae803dd9d8916bcf9 100644 (file)
@@ -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 */
 
index 21314d16ecb362e90f01a2b21148a36bdf683fb4..f1b47cb47fd8d9c3257788828118e1cb2d6501c3 100644 (file)
@@ -547,7 +547,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
         failf(data, "schannel: Failed to get certificate location"
               " or file for %s",
               data->set.ssl.primary.clientcert);
-        curlx_unicodefree(cert_path);
+        curlx_free(cert_path);
         return result;
       }
     }
@@ -558,7 +558,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
             " for %s",
             blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
       curlx_free(cert_store_path);
-      curlx_unicodefree(cert_path);
+      curlx_free(cert_path);
       if(fInCert)
         curlx_fclose(fInCert);
       return CURLE_SSL_CERTPROBLEM;
@@ -576,7 +576,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
       const char *cert_showfilename_error = blob ?
         "(memory blob)" : data->set.ssl.primary.clientcert;
       curlx_free(cert_store_path);
-      curlx_unicodefree(cert_path);
+      curlx_free(cert_path);
       if(fInCert) {
         long cert_tell = 0;
         bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0;
@@ -686,8 +686,8 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
               (path_utf8 ? path_utf8 : "(unknown)"),
               GetLastError());
         curlx_free(cert_store_path);
-        curlx_unicodefree(path_utf8);
-        curlx_unicodefree(cert_path);
+        curlx_free(path_utf8);
+        curlx_free(cert_path);
         return CURLE_SSL_CERTPROBLEM;
       }
       curlx_free(cert_store_path);
@@ -701,7 +701,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
                               cert_thumbprint_data,
                               &cert_thumbprint.cbData,
                               NULL, NULL)) {
-        curlx_unicodefree(cert_path);
+        curlx_free(cert_path);
         CertCloseStore(cert_store, 0);
         return CURLE_SSL_CERTPROBLEM;
       }
@@ -710,7 +710,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
         cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
         CERT_FIND_HASH, &cert_thumbprint, NULL);
 
-      curlx_unicodefree(cert_path);
+      curlx_free(cert_path);
 
       if(!client_certs[0]) {
         /* CRYPT_E_NOT_FOUND / E_INVALIDARG */
@@ -1485,7 +1485,7 @@ static void schannel_session_free(void *sessionid)
     cred->refcount--;
     if(cred->refcount == 0) {
       Curl_pSecFn->FreeCredentialsHandle(&cred->cred_handle);
-      curlx_unicodefree(cred->sni_hostname);
+      curlx_free(cred->sni_hostname);
       if(cred->client_cert_store) {
         CertCloseStore(cred->client_cert_store, 0);
         cred->client_cert_store = NULL;
index 77f9177349d76b81157eb02899dbfb4929b4e27d..f45977bcb607187bfa8621d1aab80c761d3690cb 100644 (file)
@@ -347,7 +347,7 @@ cleanup:
     CloseHandle(ca_file_handle);
   }
   Curl_safefree(ca_file_buffer);
-  curlx_unicodefree(ca_file_tstr);
+  curlx_free(ca_file_tstr);
 
   return result;
 }
@@ -648,7 +648,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data)
 
           result = CURLE_PEER_FAILED_VERIFICATION;
         }
-        curlx_unicodefree(cert_hostname);
+        curlx_free(cert_hostname);
       }
     }
 
index 040792f465a73763cd86f093aefb4ccdcfbe00d9..855ce0897ca105c81de106868d3ac29341f00c88 100644 (file)
@@ -593,11 +593,8 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
 
   res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr);
   if(res_len > 0) {
-    char *mstr = curlx_convert_tchar_to_UTF8(buf);
-    tool_safefree(config->cacert);
-    if(mstr)
-      config->cacert = curlx_strdup(mstr);
-    curlx_unicodefree(mstr);
+    curlx_free(config->cacert);
+    config->cacert = curlx_convert_tchar_to_UTF8(buf);
     if(!config->cacert)
       result = CURLE_OUT_OF_MEMORY;
   }
index 2d362b4bb7cbfd2ef31f98da5be50bf5e96b3655..9e548cd50e3e2be6ac69f15946db676fc58f631c 100644 (file)
@@ -47,7 +47,7 @@ int getfiletime(const char *filename, curl_off_t *stamp)
                      (FILE_SHARE_READ | FILE_SHARE_WRITE |
                       FILE_SHARE_DELETE),
                      NULL, OPEN_EXISTING, 0, NULL);
-  curlx_unicodefree(tchar_filename);
+  curlx_free(tchar_filename);
   if(hfile != INVALID_HANDLE_VALUE) {
     FILETIME ft;
     if(GetFileTime(hfile, NULL, NULL, &ft)) {
@@ -113,7 +113,7 @@ void setfiletime(curl_off_t filetime, const char *filename)
                      (FILE_SHARE_READ | FILE_SHARE_WRITE |
                       FILE_SHARE_DELETE),
                      NULL, OPEN_EXISTING, 0, NULL);
-  curlx_unicodefree(tchar_filename);
+  curlx_free(tchar_filename);
   if(hfile != INVALID_HANDLE_VALUE) {
     curl_off_t converted = ((curl_off_t)filetime * 10000000) +
       116444736000000000;
index 10b2351874362497c20679aa44607237129c3716..1b0d8017d5e56ea19ad970d0bb7c73a3521ac919 100644 (file)
@@ -383,7 +383,7 @@ ParameterError parse_args(int argc, argv_item_t argv[]);
 
 #define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr))
 #define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr))
-#define unicodefree(ptr)           curlx_unicodefree(ptr)
+#define unicodefree(ptr)           curlx_free(ptr)
 
 #else
 
index ee0b63404884758c269a2b128906b73f3a8f573c..cee68e69438fe1299f21eb89516f6704377eb915 100644 (file)
@@ -50,7 +50,7 @@ Accept: */*
 
 </protocol>
 <limits>
-Allocations: 120
+Allocations: 135
 Maximum allocated: 136000
 </limits>
 </verify>
index 127fb16270ab9a0eaf2e3e8abf150a024ab25c40..39246e49789bd132d50c69c9e9eba48f3b967614 100644 (file)
@@ -74,7 +74,7 @@ https://this.hsts.example./%TESTNUMBER
 56
 </errorcode>
 <limits>
-Allocations: 145
+Allocations: 160
 </limits>
 </verify>
 </testcase>
index 83d68841b0109dc6e665ee23118f3611cce11c72..7561c8adba42465837e19f30038bf29c40efd07b 100644 (file)
@@ -51,7 +51,7 @@ Accept: */*
 
 </protocol>
 <limits>
-Allocations: 120
+Allocations: 135
 Maximum allocated: 136000
 </limits>
 </verify>
index 7dbdf7b94a91a778b0f643cde33c4ac5a04d1be8..8c7515e4ff047198ada4405f28ba224ea618272b 100644 (file)
@@ -191,7 +191,8 @@ sub memanalyze {
 
                 if($sizeataddr{$addr} && $sizeataddr{$addr}>0) {
                     # this means weeeeeirdo
-                    push @res, "Mixed debug compile, rebuild curl now\n";
+                    push @res, "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n";
+                    push @res, "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n";
                 }
 
                 $sizeataddr{$addr} = $size;