← Commit list

a3fcd80de4

Viktor Szakats
Viktor Szakats
2025-12-01
SUCCESS Duration: 402s

Subject

curlx: use curlx allocators in non-memdebug builds (Windows)

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/curlx/fopen.c+17 -33
@@ -100,8 +100,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
goto cleanup;
if(!needed || needed >= max_path_len)
goto cleanup;
- /* !checksrc! disable BANNEDFUNC 1 */
- ibuf = malloc(needed * sizeof(wchar_t));
+ ibuf = CURLX_MALLOC(needed * sizeof(wchar_t));
if(!ibuf)
goto cleanup;
if(mbstowcs_s(&count, ibuf, needed, in, needed - 1))
@@ -122,8 +121,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
/* skip paths that are not excessive and do not need modification */
if(needed <= MAX_PATH)
goto cleanup;
- /* !checksrc! disable BANNEDFUNC 1 */
- fbuf = malloc(needed * sizeof(wchar_t));
+ fbuf = CURLX_MALLOC(needed * sizeof(wchar_t));
if(!fbuf)
goto cleanup;
count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL);
@@ -156,19 +154,16 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
if(needed > max_path_len)
goto cleanup;
- /* !checksrc! disable BANNEDFUNC 1 */
- temp = malloc(needed * sizeof(wchar_t));
+ temp = CURLX_MALLOC(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(temp);
+ CURLX_FREE(temp);
goto cleanup;
}
if(wcscpy_s(temp + 8, needed, fbuf + 2)) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(temp);
+ CURLX_FREE(temp);
goto cleanup;
}
}
@@ -178,25 +173,21 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
if(needed > max_path_len)
goto cleanup;
- /* !checksrc! disable BANNEDFUNC 1 */
- temp = malloc(needed * sizeof(wchar_t));
+ temp = CURLX_MALLOC(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(temp);
+ CURLX_FREE(temp);
goto cleanup;
}
if(wcscpy_s(temp + 4, needed, fbuf)) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(temp);
+ CURLX_FREE(temp);
goto cleanup;
}
}
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fbuf);
+ CURLX_FREE(fbuf);
fbuf = temp;
}
@@ -206,8 +197,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
goto cleanup;
if(!needed || needed >= max_path_len)
goto cleanup;
- /* !checksrc! disable BANNEDFUNC 1 */
- obuf = malloc(needed);
+ obuf = CURLX_MALLOC(needed);
if(!obuf)
goto cleanup;
if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1))
@@ -222,12 +212,10 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
#endif
cleanup:
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fbuf);
+ CURLX_FREE(fbuf);
#ifndef _UNICODE
- /* !checksrc! disable BANNEDFUNC 2 */
- free(ibuf);
- free(obuf);
+ CURLX_FREE(ibuf);
+ CURLX_FREE(obuf);
#endif
return *out ? true : false;
}
@@ -269,8 +257,7 @@ int curlx_win32_open(const char *filename, int oflag, ...)
errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode);
#endif
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fixed);
+ CURLX_FREE(fixed);
return result;
}
@@ -303,8 +290,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
errno = fopen_s(&result, target, mode);
#endif
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fixed);
+ CURLX_FREE(fixed);
return result;
}
@@ -342,8 +328,7 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp)
errno = freopen_s(&result, target, mode, fp);
#endif
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fixed);
+ CURLX_FREE(fixed);
return result;
}
@@ -382,8 +367,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
#endif
#endif
- /* !checksrc! disable BANNEDFUNC 1 */
- free(fixed);
+ CURLX_FREE(fixed);
return result;
}
lib/curlx/multibyte.c+4 -8
@@ -45,13 +45,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) {
- /* !checksrc! disable BANNEDFUNC 1 */
- str_w = 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) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(str_w);
+ CURLX_FREE(str_w);
return NULL;
}
}
@@ -69,13 +67,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) {
- /* !checksrc! disable BANNEDFUNC 1 */
- str_utf8 = malloc(bytes);
+ str_utf8 = CURLX_MALLOC(bytes);
if(str_utf8) {
if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
NULL, NULL) == 0) {
- /* !checksrc! disable BANNEDFUNC 1 */
- free(str_utf8);
+ CURLX_FREE(str_utf8);
return NULL;
}
}
lib/curlx/multibyte.h+14 -1
@@ -44,12 +44,20 @@
* 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
+
/* MultiByte conversions using Windows kernel32 library. */
wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8);
char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
/* the purpose of this macro is to free() without being traced by memdebug */
-#define curlx_unicodefree(ptr) free(ptr)
+#define curlx_unicodefree(ptr) CURLX_FREE(ptr)
#ifdef UNICODE
@@ -65,8 +73,13 @@ 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;