mirror of
https://github.com/curl/curl.git
synced 2026-06-19 14:15:39 +03:00
build: stop overriding standard memory allocation functions
Before this patch curl used the C preprocessor to override standard memory allocation symbols: malloc, calloc, strdup, realloc, free. The goal of these is to replace them with curl's debug wrappers in `CURLDEBUG` builds, another was to replace them with the wrappers calling user-defined allocators in libcurl. This solution needed a bunch of workarounds to avoid breaking external headers: it relied on include order to do the overriding last. For "unity" builds it needed to reset overrides before external includes. Also in test apps, which are always built as single source files. It also needed the `(symbol)` trick to avoid overrides in some places. This would still not fix cases where the standard symbols were macros. It was also fragile and difficult to figure out which was the actual function behind an alloc or free call in a specific piece of code. This in turn caused bugs where the wrong allocator was accidentally called. To avoid these problems, this patch replaces this solution with `curlx_`-prefixed allocator macros, and mapping them _once_ to either the libcurl wrappers, the debug wrappers or the standard ones, matching the rest of the code in libtests. This concludes the long journey to avoid redefining standard functions in the curl codebase. Note: I did not update `packages/OS400/*.c` sources. They did not `#include` `curl_setup.h`, `curl_memory.h` or `memdebug.h`, meaning the overrides were never applied to them. This may or may not have been correct. For now I suppressed the direct use of standard allocators via a local `.checksrc`. Probably they (except for `curlcl.c`) should be updated to include `curl_setup.h` and use the `curlx_` macros. This patch changes mappings in two places: - `lib/curl_threads.c` in libtests: Before this patch it mapped to libcurl allocators. After, it maps to standard allocators, like the rest of libtests code. - `units`: before this patch it mapped to standard allocators. After, it maps to libcurl allocators. Also: - drop all position-dependent `curl_memory.h` and `memdebug.h` includes, and delete the now unnecessary headers. - rename `Curl_tcsdup` macro to `curlx_tcsdup` and define like the other allocators. - map `curlx_strdup()` to `_strdup()` on Windows (was: `strdup()`). To fix warnings silenced via `_CRT_NONSTDC_NO_DEPRECATE`. - multibyte: map `curlx_convert_*()` to `_strdup()` on Windows (was: `strdup()`). - src: do not reuse the `strdup` name for the local replacement. - lib509: call `_strdup()` on Windows (was: `strdup()`). - test1132: delete test obsoleted by this patch. - CHECKSRC.md: update text for `SNPRINTF`. - checksrc: ban standard allocator symbols. Follow-up tob12da22db1#18866 Follow-up todb98daab05#18844 Follow-up to4deea9396b#18814 Follow-up to9678ff5b1b#18776 Follow-up to10bac43b87#18774 Follow-up to20142f5d06#18634 Follow-up tobf7375ecc5#18503 Follow-up to9863599d69#18502 Follow-up to3bb5e58c10#17827 Closes #19626
This commit is contained in:
parent
bfc3d131b6
commit
193cb00ce9
471 changed files with 1456 additions and 2785 deletions
|
|
@ -4,17 +4,22 @@
|
|||
|
||||
allowfunc atoi
|
||||
allowfunc atol
|
||||
allowfunc calloc
|
||||
allowfunc fclose
|
||||
allowfunc fdopen
|
||||
allowfunc fopen
|
||||
allowfunc fprintf
|
||||
allowfunc free
|
||||
allowfunc gmtime
|
||||
allowfunc localtime
|
||||
allowfunc malloc
|
||||
allowfunc open
|
||||
allowfunc printf
|
||||
allowfunc realloc
|
||||
allowfunc snprintf
|
||||
allowfunc socket
|
||||
allowfunc sscanf
|
||||
allowfunc strdup
|
||||
allowfunc strerror
|
||||
allowfunc vsnprintf
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ warnings are:
|
|||
`sizeof(int)` style.
|
||||
|
||||
- `SNPRINTF` - Found use of `snprintf()`. Since we use an internal replacement
|
||||
with a different return code etc, we prefer `msnprintf()`.
|
||||
with a different return code etc, we prefer `curl_msnprintf()`.
|
||||
|
||||
- `SPACEAFTERPAREN`: there was a space after open parenthesis, `( text`.
|
||||
|
||||
|
|
|
|||
|
|
@ -352,10 +352,12 @@ This is the full list of functions generally banned.
|
|||
aprintf
|
||||
atoi
|
||||
atol
|
||||
calloc
|
||||
fclose
|
||||
fdopen
|
||||
fopen
|
||||
fprintf
|
||||
free
|
||||
freeaddrinfo
|
||||
freopen
|
||||
getaddrinfo
|
||||
|
|
@ -368,11 +370,13 @@ This is the full list of functions generally banned.
|
|||
LoadLibraryExW
|
||||
LoadLibraryW
|
||||
localtime
|
||||
malloc
|
||||
mbstowcs
|
||||
msnprintf
|
||||
mvsnprintf
|
||||
open
|
||||
printf
|
||||
realloc
|
||||
recv
|
||||
send
|
||||
snprintf
|
||||
|
|
@ -382,6 +386,7 @@ This is the full list of functions generally banned.
|
|||
sscanf
|
||||
stat
|
||||
strcat
|
||||
strdup
|
||||
strerror
|
||||
strncat
|
||||
strncpy
|
||||
|
|
|
|||
|
|
@ -300,8 +300,6 @@ LIB_HFILES = \
|
|||
curl_ldap.h \
|
||||
curl_md4.h \
|
||||
curl_md5.h \
|
||||
curl_mem_undef.h \
|
||||
curl_memory.h \
|
||||
curl_memrchr.h \
|
||||
curl_ntlm_core.h \
|
||||
curl_printf.h \
|
||||
|
|
@ -353,7 +351,6 @@ LIB_HFILES = \
|
|||
imap.h \
|
||||
llist.h \
|
||||
macos.h \
|
||||
memdebug.h \
|
||||
mime.h \
|
||||
mqtt.h \
|
||||
multihandle.h \
|
||||
|
|
|
|||
24
lib/altsvc.c
24
lib/altsvc.c
|
|
@ -42,10 +42,6 @@
|
|||
#include "curlx/strparse.h"
|
||||
#include "connect.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define MAX_ALTSVC_LINE 4095
|
||||
#define MAX_ALTSVC_DATELEN 256
|
||||
#define MAX_ALTSVC_HOSTLEN 2048
|
||||
|
|
@ -71,9 +67,9 @@ const char *Curl_alpnid2str(enum alpnid id)
|
|||
|
||||
static void altsvc_free(struct altsvc *as)
|
||||
{
|
||||
free(as->src.host);
|
||||
free(as->dst.host);
|
||||
free(as);
|
||||
curlx_free(as->src.host);
|
||||
curlx_free(as->dst.host);
|
||||
curlx_free(as);
|
||||
}
|
||||
|
||||
static struct altsvc *altsvc_createid(const char *srchost,
|
||||
|
|
@ -85,7 +81,7 @@ static struct altsvc *altsvc_createid(const char *srchost,
|
|||
size_t srcport,
|
||||
size_t dstport)
|
||||
{
|
||||
struct altsvc *as = calloc(1, sizeof(struct altsvc));
|
||||
struct altsvc *as = curlx_calloc(1, sizeof(struct altsvc));
|
||||
if(!as)
|
||||
return NULL;
|
||||
DEBUGASSERT(hlen);
|
||||
|
|
@ -219,8 +215,8 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
|
|||
|
||||
/* we need a private copy of the filename so that the altsvc cache file
|
||||
name survives an easy handle reset */
|
||||
free(asi->filename);
|
||||
asi->filename = strdup(file);
|
||||
curlx_free(asi->filename);
|
||||
asi->filename = curlx_strdup(file);
|
||||
if(!asi->filename)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -299,7 +295,7 @@ static CURLcode altsvc_out(struct altsvc *as, FILE *fp)
|
|||
*/
|
||||
struct altsvcinfo *Curl_altsvc_init(void)
|
||||
{
|
||||
struct altsvcinfo *asi = calloc(1, sizeof(struct altsvcinfo));
|
||||
struct altsvcinfo *asi = curlx_calloc(1, sizeof(struct altsvcinfo));
|
||||
if(!asi)
|
||||
return NULL;
|
||||
Curl_llist_init(&asi->list, NULL);
|
||||
|
|
@ -350,8 +346,8 @@ void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp)
|
|||
n = Curl_node_next(e);
|
||||
altsvc_free(as);
|
||||
}
|
||||
free(altsvc->filename);
|
||||
free(altsvc);
|
||||
curlx_free(altsvc->filename);
|
||||
curlx_free(altsvc);
|
||||
*altsvcp = NULL; /* clear the pointer */
|
||||
}
|
||||
}
|
||||
|
|
@ -399,7 +395,7 @@ CURLcode Curl_altsvc_save(struct Curl_easy *data,
|
|||
if(result && tempstore)
|
||||
unlink(tempstore);
|
||||
}
|
||||
free(tempstore);
|
||||
curlx_free(tempstore);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* The last #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef HAVE_PROTO_BSDSOCKET_H
|
||||
|
||||
#ifdef __amigaos4__
|
||||
|
|
@ -135,7 +131,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
LONG h_errnop = 0;
|
||||
struct hostent *buf;
|
||||
|
||||
buf = calloc(1, CURL_HOSTENT_SIZE);
|
||||
buf = curlx_calloc(1, CURL_HOSTENT_SIZE);
|
||||
if(buf) {
|
||||
h = gethostbyname_r((STRPTR)hostname, buf,
|
||||
(char *)buf + sizeof(struct hostent),
|
||||
|
|
@ -144,7 +140,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
if(h) {
|
||||
ai = Curl_he2ai(h, port);
|
||||
}
|
||||
free(buf);
|
||||
curlx_free(buf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -104,10 +104,6 @@
|
|||
#define HTTPSRR_WORKS
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define CARES_TIMEOUT_PER_ATTEMPT 2000
|
||||
|
||||
static int ares_ver = 0;
|
||||
|
|
@ -633,7 +629,7 @@ async_ares_node2addr(struct ares_addrinfo_node *node)
|
|||
if((size_t)ai->ai_addrlen < ss_size)
|
||||
continue;
|
||||
|
||||
ca = malloc(sizeof(struct Curl_addrinfo) + ss_size);
|
||||
ca = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size);
|
||||
if(!ca) {
|
||||
error = EAI_MEMORY;
|
||||
break;
|
||||
|
|
@ -736,7 +732,7 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname,
|
|||
data->state.async.dns = NULL; /* clear */
|
||||
data->state.async.port = port;
|
||||
data->state.async.ip_version = ip_version;
|
||||
data->state.async.hostname = strdup(hostname);
|
||||
data->state.async.hostname = curlx_strdup(hostname);
|
||||
if(!data->state.async.hostname)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
#ifdef USE_HTTPSRR
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@
|
|||
#include "select.h"
|
||||
#include "curl_share.h"
|
||||
#include "url.h"
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
/***********************************************************************
|
||||
* Only for builds using asynchronous name resolves
|
||||
|
|
|
|||
|
|
@ -72,10 +72,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
/*
|
||||
* Curl_async_global_init()
|
||||
|
|
@ -136,7 +132,7 @@ static void addr_ctx_unlink(struct async_thrdd_addr_ctx **paddr_ctx,
|
|||
|
||||
if(destroy) {
|
||||
Curl_mutex_destroy(&addr_ctx->mutx);
|
||||
free(addr_ctx->hostname);
|
||||
curlx_free(addr_ctx->hostname);
|
||||
if(addr_ctx->res)
|
||||
Curl_freeaddrinfo(addr_ctx->res);
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
|
|
@ -145,7 +141,7 @@ static void addr_ctx_unlink(struct async_thrdd_addr_ctx **paddr_ctx,
|
|||
#endif
|
||||
wakeup_close(addr_ctx->sock_pair[0]);
|
||||
#endif
|
||||
free(addr_ctx);
|
||||
curlx_free(addr_ctx);
|
||||
}
|
||||
*paddr_ctx = NULL;
|
||||
}
|
||||
|
|
@ -156,7 +152,7 @@ addr_ctx_create(struct Curl_easy *data,
|
|||
const char *hostname, int port,
|
||||
const struct addrinfo *hints)
|
||||
{
|
||||
struct async_thrdd_addr_ctx *addr_ctx = calloc(1, sizeof(*addr_ctx));
|
||||
struct async_thrdd_addr_ctx *addr_ctx = curlx_calloc(1, sizeof(*addr_ctx));
|
||||
if(!addr_ctx)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -186,7 +182,7 @@ addr_ctx_create(struct Curl_easy *data,
|
|||
/* Copying hostname string because original can be destroyed by parent
|
||||
* thread during gethostbyname execution.
|
||||
*/
|
||||
addr_ctx->hostname = strdup(hostname);
|
||||
addr_ctx->hostname = curlx_strdup(hostname);
|
||||
if(!addr_ctx->hostname)
|
||||
goto err_exit;
|
||||
|
||||
|
|
@ -376,7 +372,7 @@ static CURLcode async_rr_start(struct Curl_easy *data, int port)
|
|||
status = ares_init_options(&thrdd->rr.channel, NULL, 0);
|
||||
if(status != ARES_SUCCESS) {
|
||||
thrdd->rr.channel = NULL;
|
||||
free(rrname);
|
||||
curlx_free(rrname);
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
#ifdef CURLDEBUG
|
||||
|
|
@ -384,7 +380,7 @@ static CURLcode async_rr_start(struct Curl_easy *data, int port)
|
|||
const char *servers = getenv("CURL_DNS_SERVER");
|
||||
status = ares_set_servers_ports_csv(thrdd->rr.channel, servers);
|
||||
if(status) {
|
||||
free(rrname);
|
||||
curlx_free(rrname);
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,8 +431,8 @@ static bool async_thrdd_init(struct Curl_easy *data,
|
|||
data->state.async.done = FALSE;
|
||||
data->state.async.port = port;
|
||||
data->state.async.ip_version = ip_version;
|
||||
free(data->state.async.hostname);
|
||||
data->state.async.hostname = strdup(hostname);
|
||||
curlx_free(data->state.async.hostname);
|
||||
data->state.async.hostname = curlx_strdup(hostname);
|
||||
if(!data->state.async.hostname)
|
||||
goto err_exit;
|
||||
|
||||
|
|
|
|||
14
lib/bufq.c
14
lib/bufq.c
|
|
@ -25,10 +25,6 @@
|
|||
#include "curl_setup.h"
|
||||
#include "bufq.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static bool chunk_is_empty(const struct buf_chunk *chunk)
|
||||
{
|
||||
return chunk->r_offset >= chunk->w_offset;
|
||||
|
|
@ -143,7 +139,7 @@ static void chunk_list_free(struct buf_chunk **anchor)
|
|||
while(*anchor) {
|
||||
chunk = *anchor;
|
||||
*anchor = chunk->next;
|
||||
free(chunk);
|
||||
curlx_free(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +174,7 @@ static CURLcode bufcp_take(struct bufc_pool *pool,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
chunk = calloc(1, sizeof(*chunk) + pool->chunk_size);
|
||||
chunk = curlx_calloc(1, sizeof(*chunk) + pool->chunk_size);
|
||||
if(!chunk) {
|
||||
*pchunk = NULL;
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -192,7 +188,7 @@ static void bufcp_put(struct bufc_pool *pool,
|
|||
struct buf_chunk *chunk)
|
||||
{
|
||||
if(pool->spare_count >= pool->spare_max) {
|
||||
free(chunk);
|
||||
curlx_free(chunk);
|
||||
}
|
||||
else {
|
||||
chunk_reset(chunk);
|
||||
|
|
@ -311,7 +307,7 @@ static struct buf_chunk *get_spare(struct bufq *q)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
chunk = calloc(1, sizeof(*chunk) + q->chunk_size);
|
||||
chunk = curlx_calloc(1, sizeof(*chunk) + q->chunk_size);
|
||||
if(!chunk)
|
||||
return NULL;
|
||||
chunk->dlen = q->chunk_size;
|
||||
|
|
@ -338,7 +334,7 @@ static void prune_head(struct bufq *q)
|
|||
/* SOFT_LIMIT allowed us more than max. free spares until
|
||||
* we are at max again. Or free them if we are configured
|
||||
* to not use spares. */
|
||||
free(chunk);
|
||||
curlx_free(chunk);
|
||||
--q->chunk_count;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@
|
|||
#include "bufref.h"
|
||||
#include "strdup.h"
|
||||
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
#define SIGNATURE 0x5c48e9b2 /* Random pattern. */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,10 +46,6 @@
|
|||
#include "multiif.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
H1_TUNNEL_INIT, /* init/default/no tunnel state */
|
||||
|
|
@ -116,7 +112,7 @@ static CURLcode tunnel_init(struct Curl_cfilter *cf,
|
|||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
}
|
||||
|
||||
ts = calloc(1, sizeof(*ts));
|
||||
ts = curlx_calloc(1, sizeof(*ts));
|
||||
if(!ts)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -194,7 +190,7 @@ static void tunnel_free(struct Curl_cfilter *cf,
|
|||
curlx_dyn_free(&ts->rcvbuf);
|
||||
curlx_dyn_free(&ts->request_data);
|
||||
Curl_httpchunk_free(data, &ts->ch);
|
||||
free(ts);
|
||||
curlx_free(ts);
|
||||
cf->ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -215,7 +211,7 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf,
|
|||
|
||||
/* This only happens if we have looped here due to authentication
|
||||
reasons, and we do not really use the newly cloned URL here
|
||||
then. Just free() it. */
|
||||
then. Just free it. */
|
||||
Curl_safefree(data->req.newurl);
|
||||
|
||||
result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1);
|
||||
|
|
@ -298,7 +294,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
|
|||
CURL_TRC_CF(data, cf, "CONNECT: fwd auth header '%s'", header);
|
||||
result = Curl_http_input_auth(data, proxy, auth);
|
||||
|
||||
free(auth);
|
||||
curlx_free(auth);
|
||||
|
||||
if(result)
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "cf-h2-proxy.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define PROXY_H2_CHUNK_SIZE (16*1024)
|
||||
|
||||
#define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024)
|
||||
|
|
@ -209,7 +205,7 @@ static void cf_h2_proxy_ctx_free(struct cf_h2_proxy_ctx *ctx)
|
|||
{
|
||||
if(ctx) {
|
||||
cf_h2_proxy_ctx_clear(ctx);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -919,7 +915,7 @@ static CURLcode proxy_h2_submit(int32_t *pstream_id,
|
|||
result = CURLE_OK;
|
||||
|
||||
out:
|
||||
free(nva);
|
||||
curlx_free(nva);
|
||||
Curl_dynhds_free(&h2_headers);
|
||||
*pstream_id = stream_id;
|
||||
return result;
|
||||
|
|
@ -1594,7 +1590,7 @@ CURLcode Curl_cf_h2_proxy_insert_after(struct Curl_cfilter *cf,
|
|||
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||
|
||||
(void)data;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx)
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@
|
|||
#include "multiif.h"
|
||||
#include "select.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
HAPROXY_INIT, /* init/default/no tunnel state */
|
||||
|
|
@ -61,7 +57,7 @@ static void cf_haproxy_ctx_free(struct cf_haproxy_ctx *ctx)
|
|||
{
|
||||
if(ctx) {
|
||||
curlx_dyn_free(&ctx->data_out);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +213,7 @@ static CURLcode cf_haproxy_create(struct Curl_cfilter **pcf,
|
|||
CURLcode result;
|
||||
|
||||
(void)data;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@
|
|||
#include "select.h"
|
||||
#include "vquic/vquic.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef enum {
|
||||
CF_HC_INIT,
|
||||
CF_HC_CONNECT,
|
||||
|
|
@ -588,7 +584,7 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
|||
CURLcode result = CURLE_OK;
|
||||
size_t i;
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -618,7 +614,7 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
|||
|
||||
out:
|
||||
*pcf = result ? NULL : cf;
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@
|
|||
#include "select.h"
|
||||
#include "vquic/vquic.h" /* for quic cfilters */
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
struct transport_provider {
|
||||
uint8_t transport;
|
||||
|
|
@ -186,7 +182,7 @@ static void cf_ip_attempt_free(struct cf_ip_attempt *a,
|
|||
if(a) {
|
||||
if(a->cf)
|
||||
Curl_conn_cf_discard_chain(&a->cf, data);
|
||||
free(a);
|
||||
curlx_free(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +199,7 @@ static CURLcode cf_ip_attempt_new(struct cf_ip_attempt **pa,
|
|||
CURLcode result = CURLE_OK;
|
||||
|
||||
*pa = NULL;
|
||||
a = calloc(1, sizeof(*a));
|
||||
a = curlx_calloc(1, sizeof(*a));
|
||||
if(!a)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -941,7 +937,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf,
|
|||
(void)data;
|
||||
(void)conn;
|
||||
*pcf = NULL;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -954,7 +950,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf,
|
|||
out:
|
||||
if(result) {
|
||||
Curl_safefree(*pcf);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,10 +82,6 @@
|
|||
#include "curlx/strerr.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#if defined(USE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32)
|
||||
/* It makes support for IPv4-mapped IPv6 addresses.
|
||||
|
|
@ -555,7 +551,7 @@ CURLcode Curl_parse_interface(const char *input,
|
|||
++host_part;
|
||||
*host = Curl_memdup0(host_part, len - (host_part - input));
|
||||
if(!*host) {
|
||||
free(*iface);
|
||||
curlx_free(*iface);
|
||||
*iface = NULL;
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -1026,7 +1022,7 @@ static void cf_socket_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
|
||||
cf_socket_close(cf, data);
|
||||
CURL_TRC_CF(data, cf, "destroy");
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
cf->ctx = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1758,7 +1754,7 @@ CURLcode Curl_cf_tcp_create(struct Curl_cfilter **pcf,
|
|||
goto out;
|
||||
}
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -1920,7 +1916,7 @@ CURLcode Curl_cf_udp_create(struct Curl_cfilter **pcf,
|
|||
(void)data;
|
||||
(void)conn;
|
||||
DEBUGASSERT(transport == TRNSPRT_UDP || transport == TRNSPRT_QUIC);
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -1974,7 +1970,7 @@ CURLcode Curl_cf_unix_create(struct Curl_cfilter **pcf,
|
|||
(void)data;
|
||||
(void)conn;
|
||||
DEBUGASSERT(transport == TRNSPRT_UNIX);
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -2199,7 +2195,7 @@ CURLcode Curl_conn_tcp_listen_set(struct Curl_easy *data,
|
|||
Curl_conn_cf_discard_all(data, conn, sockindex);
|
||||
DEBUGASSERT(conn->sock[sockindex] == CURL_SOCKET_BAD);
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static void cf_cntrl_update_info(struct Curl_easy *data,
|
||||
struct connectdata *conn);
|
||||
|
||||
|
|
@ -143,7 +139,7 @@ void Curl_conn_cf_discard_chain(struct Curl_cfilter **pcf,
|
|||
*/
|
||||
cf->next = NULL;
|
||||
cf->cft->destroy(cf, data);
|
||||
free(cf);
|
||||
curlx_free(cf);
|
||||
cf = cfn;
|
||||
}
|
||||
}
|
||||
|
|
@ -332,7 +328,7 @@ CURLcode Curl_cf_create(struct Curl_cfilter **pcf,
|
|||
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||
|
||||
DEBUGASSERT(cft);
|
||||
cf = calloc(1, sizeof(*cf));
|
||||
cf = curlx_calloc(1, sizeof(*cf));
|
||||
if(!cf)
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@
|
|||
#include "curlx/strparse.h"
|
||||
#include "uint-table.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#define CPOOL_IS_LOCKED(c) ((c) && (c)->locked)
|
||||
|
||||
|
|
@ -92,7 +88,7 @@ static struct cpool_bundle *cpool_bundle_create(const char *dest)
|
|||
struct cpool_bundle *bundle;
|
||||
size_t dest_len = strlen(dest) + 1;
|
||||
|
||||
bundle = calloc(1, sizeof(*bundle) + dest_len - 1);
|
||||
bundle = curlx_calloc(1, sizeof(*bundle) + dest_len - 1);
|
||||
if(!bundle)
|
||||
return NULL;
|
||||
Curl_llist_init(&bundle->conns, NULL);
|
||||
|
|
@ -104,7 +100,7 @@ static struct cpool_bundle *cpool_bundle_create(const char *dest)
|
|||
static void cpool_bundle_destroy(struct cpool_bundle *bundle)
|
||||
{
|
||||
DEBUGASSERT(!Curl_llist_count(&bundle->conns));
|
||||
free(bundle);
|
||||
curlx_free(bundle);
|
||||
}
|
||||
|
||||
/* Add a connection to a bundle */
|
||||
|
|
|
|||
|
|
@ -76,10 +76,6 @@
|
|||
#include "http_proxy.h"
|
||||
#include "socks.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
|
||||
|
||||
enum alpnid Curl_alpn2alpnid(const unsigned char *name, size_t len)
|
||||
|
|
@ -527,7 +523,7 @@ static CURLcode cf_setup_create(struct Curl_cfilter **pcf,
|
|||
CURLcode result = CURLE_OK;
|
||||
|
||||
(void)data;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -544,7 +540,7 @@ static CURLcode cf_setup_create(struct Curl_cfilter **pcf,
|
|||
out:
|
||||
*pcf = result ? NULL : cf;
|
||||
if(ctx) {
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@
|
|||
#include "http.h"
|
||||
#include "content_encoding.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define CONTENT_ENCODING_DEFAULT "identity"
|
||||
|
||||
#ifndef CURL_DISABLE_HTTP
|
||||
|
|
@ -95,15 +91,15 @@ static voidpf
|
|||
zalloc_cb(voidpf opaque, unsigned int items, unsigned int size)
|
||||
{
|
||||
(void)opaque;
|
||||
/* not a typo, keep it calloc() */
|
||||
return (voidpf) calloc(items, size);
|
||||
/* not a typo, keep it curlx_calloc() */
|
||||
return (voidpf)curlx_calloc(items, size);
|
||||
}
|
||||
|
||||
static void
|
||||
zfree_cb(voidpf opaque, voidpf ptr)
|
||||
{
|
||||
(void)opaque;
|
||||
free(ptr);
|
||||
curlx_free(ptr);
|
||||
}
|
||||
|
||||
static CURLcode
|
||||
|
|
|
|||
54
lib/cookie.c
54
lib/cookie.c
|
|
@ -42,10 +42,6 @@
|
|||
#include "llist.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static void strstore(char **str, const char *newstr, size_t len);
|
||||
|
||||
/* number of seconds in 400 days */
|
||||
|
|
@ -70,12 +66,12 @@ static void cap_expires(time_t now, struct Cookie *co)
|
|||
|
||||
static void freecookie(struct Cookie *co)
|
||||
{
|
||||
free(co->domain);
|
||||
free(co->path);
|
||||
free(co->spath);
|
||||
free(co->name);
|
||||
free(co->value);
|
||||
free(co);
|
||||
curlx_free(co->domain);
|
||||
curlx_free(co->path);
|
||||
curlx_free(co->spath);
|
||||
curlx_free(co->name);
|
||||
curlx_free(co->value);
|
||||
curlx_free(co);
|
||||
}
|
||||
|
||||
static bool cookie_tailmatch(const char *cookie_domain,
|
||||
|
|
@ -246,7 +242,7 @@ static char *sanitize_cookie_path(const char *cookie_path)
|
|||
/* RFC6265 5.2.4 The Path Attribute */
|
||||
if(cookie_path[0] != '/')
|
||||
/* Let cookie-path be the default-path. */
|
||||
return strdup("/");
|
||||
return curlx_strdup("/");
|
||||
|
||||
/* remove trailing slash when path is non-empty */
|
||||
/* convert /hoge/ to /hoge */
|
||||
|
|
@ -268,7 +264,7 @@ static char *sanitize_cookie_path(const char *cookie_path)
|
|||
static void strstore(char **str, const char *newstr, size_t len)
|
||||
{
|
||||
DEBUGASSERT(str);
|
||||
free(*str);
|
||||
curlx_free(*str);
|
||||
if(!len) {
|
||||
len++;
|
||||
newstr = "";
|
||||
|
|
@ -506,7 +502,7 @@ parse_cookie_header(struct Curl_easy *data,
|
|||
strstore(&co->path, curlx_str(&val), curlx_strlen(&val));
|
||||
if(!co->path)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
free(co->spath); /* if this is set again */
|
||||
curlx_free(co->spath); /* if this is set again */
|
||||
co->spath = sanitize_cookie_path(co->path);
|
||||
if(!co->spath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -631,7 +627,7 @@ parse_cookie_header(struct Curl_easy *data,
|
|||
|
||||
if(!co->domain && domain) {
|
||||
/* no domain was given in the header line, set the default */
|
||||
co->domain = strdup(domain);
|
||||
co->domain = curlx_strdup(domain);
|
||||
if(!co->domain)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -739,10 +735,10 @@ parse_netscape(struct Cookie *co,
|
|||
break;
|
||||
}
|
||||
/* this does not look like a path, make one up! */
|
||||
co->path = strdup("/");
|
||||
co->path = curlx_strdup("/");
|
||||
if(!co->path)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
co->spath = strdup("/");
|
||||
co->spath = curlx_strdup("/");
|
||||
if(!co->spath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
fields++; /* add a field and fall down to secure */
|
||||
|
|
@ -781,7 +777,7 @@ parse_netscape(struct Cookie *co,
|
|||
}
|
||||
if(fields == 6) {
|
||||
/* we got a cookie with blank contents, fix it */
|
||||
co->value = strdup("");
|
||||
co->value = curlx_strdup("");
|
||||
if(!co->value)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
else
|
||||
|
|
@ -981,7 +977,7 @@ Curl_cookie_add(struct Curl_easy *data,
|
|||
return CURLE_OK; /* silently ignore */
|
||||
|
||||
/* First, alloc and init a new struct for it */
|
||||
co = calloc(1, sizeof(struct Cookie));
|
||||
co = curlx_calloc(1, sizeof(struct Cookie));
|
||||
if(!co)
|
||||
return CURLE_OUT_OF_MEMORY; /* bail out if we are this low on memory */
|
||||
|
||||
|
|
@ -1081,7 +1077,7 @@ fail:
|
|||
struct CookieInfo *Curl_cookie_init(void)
|
||||
{
|
||||
int i;
|
||||
struct CookieInfo *ci = calloc(1, sizeof(struct CookieInfo));
|
||||
struct CookieInfo *ci = curlx_calloc(1, sizeof(struct CookieInfo));
|
||||
if(!ci)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -1343,7 +1339,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data,
|
|||
size_t i;
|
||||
|
||||
/* alloc an array and store all cookie pointers */
|
||||
array = malloc(sizeof(struct Cookie *) * matches);
|
||||
array = curlx_malloc(sizeof(struct Cookie *) * matches);
|
||||
if(!array) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -1363,7 +1359,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data,
|
|||
for(i = 0; i < matches; i++)
|
||||
Curl_llist_append(list, array[i], &array[i]->getnode);
|
||||
|
||||
free(array); /* remove the temporary data again */
|
||||
curlx_free(array); /* remove the temporary data again */
|
||||
}
|
||||
|
||||
*okay = TRUE;
|
||||
|
|
@ -1435,7 +1431,7 @@ void Curl_cookie_cleanup(struct CookieInfo *ci)
|
|||
{
|
||||
if(ci) {
|
||||
Curl_cookie_clearall(ci);
|
||||
free(ci); /* free the base struct as well */
|
||||
curlx_free(ci); /* free the base struct as well */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1518,7 +1514,7 @@ static CURLcode cookie_output(struct Curl_easy *data,
|
|||
struct Cookie **array;
|
||||
struct Curl_llist_node *n;
|
||||
|
||||
array = calloc(1, sizeof(struct Cookie *) * ci->numcookies);
|
||||
array = curlx_calloc(1, sizeof(struct Cookie *) * ci->numcookies);
|
||||
if(!array) {
|
||||
error = CURLE_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
|
|
@ -1540,15 +1536,15 @@ static CURLcode cookie_output(struct Curl_easy *data,
|
|||
for(i = 0; i < nvalid; i++) {
|
||||
char *format_ptr = get_netscape_format(array[i]);
|
||||
if(!format_ptr) {
|
||||
free(array);
|
||||
curlx_free(array);
|
||||
error = CURLE_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
curl_mfprintf(out, "%s\n", format_ptr);
|
||||
free(format_ptr);
|
||||
curlx_free(format_ptr);
|
||||
}
|
||||
|
||||
free(array);
|
||||
curlx_free(array);
|
||||
}
|
||||
|
||||
if(!use_stdout) {
|
||||
|
|
@ -1565,7 +1561,7 @@ static CURLcode cookie_output(struct Curl_easy *data,
|
|||
* no need to inspect the error, any error case should have jumped into the
|
||||
* error block below.
|
||||
*/
|
||||
free(tempstore);
|
||||
curlx_free(tempstore);
|
||||
return CURLE_OK;
|
||||
|
||||
error:
|
||||
|
|
@ -1573,7 +1569,7 @@ error:
|
|||
curlx_fclose(out);
|
||||
if(tempstore) {
|
||||
unlink(tempstore);
|
||||
free(tempstore);
|
||||
curlx_free(tempstore);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
|
@ -1605,7 +1601,7 @@ static struct curl_slist *cookie_list(struct Curl_easy *data)
|
|||
}
|
||||
beg = Curl_slist_append_nodup(list, line);
|
||||
if(!beg) {
|
||||
free(line);
|
||||
curlx_free(line);
|
||||
curl_slist_free_all(list);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@
|
|||
#include "select.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
static void cshutdn_run_conn_handler(struct Curl_easy *data,
|
||||
struct connectdata *conn)
|
||||
|
|
|
|||
|
|
@ -54,10 +54,6 @@
|
|||
#include "curlx/inet_pton.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Curl_freeaddrinfo()
|
||||
*
|
||||
|
|
@ -83,7 +79,7 @@ Curl_freeaddrinfo(struct Curl_addrinfo *cahead)
|
|||
|
||||
for(ca = cahead; ca; ca = canext) {
|
||||
canext = ca->ai_next;
|
||||
free(ca);
|
||||
curlx_free(ca);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +142,7 @@ Curl_getaddrinfo_ex(const char *nodename,
|
|||
if((size_t)ai->ai_addrlen < ss_size)
|
||||
continue;
|
||||
|
||||
ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
|
||||
ca = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
|
||||
if(!ca) {
|
||||
error = EAI_MEMORY;
|
||||
break;
|
||||
|
|
@ -285,7 +281,7 @@ Curl_he2ai(const struct hostent *he, int port)
|
|||
ss_size = sizeof(struct sockaddr_in);
|
||||
|
||||
/* allocate memory to hold the struct, the address and the name */
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
|
||||
ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
|
||||
if(!ai) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
@ -382,7 +378,7 @@ ip2addr(struct Curl_addrinfo **addrp,
|
|||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
/* allocate memory to hold the struct, the address and the name */
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen);
|
||||
ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen);
|
||||
if(!ai)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
/* put the address after the struct */
|
||||
|
|
@ -471,7 +467,8 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
|
|||
|
||||
*longpath = FALSE;
|
||||
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
|
||||
ai = curlx_calloc(1,
|
||||
sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
|
||||
if(!ai)
|
||||
return NULL;
|
||||
ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
|
||||
|
|
@ -482,7 +479,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
|
|||
/* sun_path must be able to store the null-terminated path */
|
||||
path_len = strlen(path) + 1;
|
||||
if(path_len > sizeof(sa_un->sun_path)) {
|
||||
free(ai);
|
||||
curlx_free(ai);
|
||||
*longpath = TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include "curl_fnmatch.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef HAVE_FNMATCH
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
#include "rand.h"
|
||||
#include "curl_fopen.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
The dirslash() function breaks a null-terminated pathname string into
|
||||
directory and filename components then returns the directory component up
|
||||
|
|
@ -120,7 +116,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
|
|||
/* The temp filename should not end up too long for the target file
|
||||
system */
|
||||
tempstore = curl_maprintf("%s%s.tmp", dir, randbuf);
|
||||
free(dir);
|
||||
curlx_free(dir);
|
||||
}
|
||||
|
||||
if(!tempstore) {
|
||||
|
|
@ -156,7 +152,7 @@ fail:
|
|||
unlink(tempstore);
|
||||
}
|
||||
|
||||
free(tempstore);
|
||||
curlx_free(tempstore);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@
|
|||
!defined(CURL_DISABLE_HSTS) || !defined(CURL_DISABLE_NETRC)
|
||||
|
||||
#include "curl_get_line.h"
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#define appendnl(b) \
|
||||
curlx_dyn_addn(buf, "\n", 1)
|
||||
|
|
|
|||
|
|
@ -31,10 +31,8 @@
|
|||
|
||||
#ifdef DEBUGBUILD
|
||||
#if defined(HAVE_GSSGNU) || !defined(_WIN32)
|
||||
/* To avoid memdebug macro replacement, wrap the name in parentheses to call
|
||||
the original version. It is freed via the GSS API gss_release_buffer(). */
|
||||
#define Curl_gss_alloc (malloc)
|
||||
#define Curl_gss_free (free)
|
||||
#define Curl_gss_alloc malloc /* freed via the GSS API gss_release_buffer() */
|
||||
#define Curl_gss_free free /* pair of the above */
|
||||
#define CURL_GSS_STUB
|
||||
/* For correctness this would be required for all platforms, not only Windows,
|
||||
but, as of v1.22.1, MIT Kerberos uses a special allocator only for Windows,
|
||||
|
|
@ -51,10 +49,6 @@
|
|||
#endif
|
||||
#endif /* DEBUGBUILD */
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CURL_ALIGN8 __attribute__((aligned(8)))
|
||||
#else
|
||||
|
|
@ -208,7 +202,7 @@ stub_gss_init_sec_context(OM_uint32 *min,
|
|||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
*min = STUB_GSS_NO_MEMORY;
|
||||
return GSS_S_FAILURE;
|
||||
|
|
@ -225,7 +219,7 @@ stub_gss_init_sec_context(OM_uint32 *min,
|
|||
else if(ctx->have_ntlm)
|
||||
ctx->sent = STUB_GSS_NTLM1;
|
||||
else {
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
*min = STUB_GSS_NO_MECH;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
|
@ -236,7 +230,7 @@ stub_gss_init_sec_context(OM_uint32 *min,
|
|||
|
||||
token = Curl_gss_alloc(length);
|
||||
if(!token) {
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
*min = STUB_GSS_NO_MEMORY;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
|
@ -250,14 +244,14 @@ stub_gss_init_sec_context(OM_uint32 *min,
|
|||
&target_desc, &name_type);
|
||||
if(GSS_ERROR(major_status)) {
|
||||
Curl_gss_free(token);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
*min = STUB_GSS_NO_MEMORY;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
if(strlen(creds) + target_desc.length + 5 >= sizeof(ctx->creds)) {
|
||||
Curl_gss_free(token);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
*min = STUB_GSS_NO_MEMORY;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
|
@ -273,7 +267,7 @@ stub_gss_init_sec_context(OM_uint32 *min,
|
|||
|
||||
if(used >= length) {
|
||||
Curl_gss_free(token);
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
*min = STUB_GSS_NO_MEMORY;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
|
@ -308,7 +302,7 @@ stub_gss_delete_sec_context(OM_uint32 *min,
|
|||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
free(*context);
|
||||
curlx_free(*context);
|
||||
*context = NULL;
|
||||
*min = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* Unset redefined system symbols. */
|
||||
|
||||
#undef strdup
|
||||
#undef malloc
|
||||
#undef calloc
|
||||
#undef realloc
|
||||
#undef free
|
||||
#ifdef _WIN32
|
||||
#undef Curl_tcsdup
|
||||
#endif
|
||||
|
||||
#undef HEADER_CURL_MEMORY_H
|
||||
#undef HEADER_CURL_MEMDEBUG_H
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#ifndef HEADER_CURL_MEMORY_H
|
||||
#define HEADER_CURL_MEMORY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Nasty internal details ahead...
|
||||
*
|
||||
* File curl_memory.h must be included by _all_ *.c source files
|
||||
* that use memory related functions strdup, malloc, calloc, realloc
|
||||
* or free, and given source file is used to build libcurl library.
|
||||
* It should be included immediately before memdebug.h as the last files
|
||||
* included to avoid undesired interaction with other memory function
|
||||
* headers in dependent libraries.
|
||||
*
|
||||
* There is nearly no exception to above rule. All libcurl source
|
||||
* files in 'lib' subdirectory as well as those living deep inside
|
||||
* 'packages' subdirectories and linked together in order to build
|
||||
* libcurl library shall follow it.
|
||||
*
|
||||
* File lib/strdup.c is an exception, given that it provides a strdup
|
||||
* clone implementation while using malloc. Extra care needed inside
|
||||
* this one.
|
||||
*
|
||||
* The need for curl_memory.h inclusion is due to libcurl's feature
|
||||
* of allowing library user to provide memory replacement functions,
|
||||
* memory callbacks, at runtime with curl_global_init_mem()
|
||||
*
|
||||
* Any *.c source file used to build libcurl library that does not
|
||||
* include curl_memory.h and uses any memory function of the five
|
||||
* mentioned above will compile without any indication, but it will
|
||||
* trigger weird memory related issues at runtime.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CURLDEBUG
|
||||
|
||||
/*
|
||||
* libcurl's 'memory tracking' system defines strdup, malloc, calloc,
|
||||
* realloc and free, along with others, in memdebug.h in a different
|
||||
* way although still using memory callbacks forward declared above.
|
||||
* When using the 'memory tracking' system (CURLDEBUG defined) we do
|
||||
* not define here the five memory functions given that definitions
|
||||
* from memdebug.h are the ones that shall be used.
|
||||
*/
|
||||
|
||||
#undef strdup
|
||||
#define strdup(ptr) Curl_cstrdup(ptr)
|
||||
#undef malloc
|
||||
#define malloc(size) Curl_cmalloc(size)
|
||||
#undef calloc
|
||||
#define calloc(nbelem,size) Curl_ccalloc(nbelem, size)
|
||||
#undef realloc
|
||||
#define realloc(ptr,size) Curl_crealloc(ptr, size)
|
||||
#undef free
|
||||
#define free(ptr) Curl_cfree(ptr)
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef Curl_tcsdup
|
||||
#ifdef UNICODE
|
||||
#define Curl_tcsdup(ptr) Curl_wcsdup(ptr)
|
||||
#else
|
||||
#define Curl_tcsdup(ptr) Curl_cstrdup(ptr)
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* CURLDEBUG */
|
||||
#endif /* HEADER_CURL_MEMORY_H */
|
||||
|
|
@ -27,10 +27,6 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include "curl_memrchr.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef HAVE_MEMRCHR
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -122,10 +122,6 @@
|
|||
#include "curl_endian.h"
|
||||
#include "curl_md4.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef USE_CURL_DES_SET_ODD_PARITY
|
||||
/*
|
||||
* curl_des_set_odd_parity()
|
||||
|
|
@ -437,7 +433,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password,
|
|||
CURLcode result;
|
||||
if(len > SIZE_MAX/2) /* avoid integer overflow */
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
pw = len ? malloc(len * 2) : (unsigned char *)strdup("");
|
||||
pw = len ? curlx_malloc(len * 2) : (unsigned char *)curlx_strdup("");
|
||||
if(!pw)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -448,7 +444,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password,
|
|||
if(!result)
|
||||
memset(ntbuffer + 16, 0, 21 - 16);
|
||||
|
||||
free(pw);
|
||||
curlx_free(pw);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -525,7 +521,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
identity_len = (userlen + domlen) * 2;
|
||||
identity = malloc(identity_len + 1);
|
||||
identity = curlx_malloc(identity_len + 1);
|
||||
|
||||
if(!identity)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -535,7 +531,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
|
|||
|
||||
result = Curl_hmacit(&Curl_HMAC_MD5, ntlmhash, 16, identity, identity_len,
|
||||
ntlmv2hash);
|
||||
free(identity);
|
||||
curlx_free(identity);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -598,7 +594,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
|
|||
len = HMAC_MD5_LENGTH + NTLMv2_BLOB_LEN;
|
||||
|
||||
/* Allocate the response */
|
||||
ptr = calloc(1, len);
|
||||
ptr = curlx_calloc(1, len);
|
||||
if(!ptr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -622,7 +618,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
|
|||
result = Curl_hmacit(&Curl_HMAC_MD5, ntlmv2hash, HMAC_MD5_LENGTH, ptr + 8,
|
||||
NTLMv2_BLOB_LEN + 8, hmac_output);
|
||||
if(result) {
|
||||
free(ptr);
|
||||
curlx_free(ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
#include <curl/curl.h>
|
||||
#include <librtmp/rtmp.h>
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(USE_LWIPSOCK)
|
||||
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
|
||||
#define SET_RCVTIMEO(tv,s) int tv = s*1000
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "sendf.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Supported mechanisms */
|
||||
static const struct {
|
||||
const char *name; /* Name */
|
||||
|
|
|
|||
|
|
@ -941,7 +941,7 @@ extern curl_calloc_callback Curl_ccalloc;
|
|||
* This macro also assigns NULL to given pointer when free'd.
|
||||
*/
|
||||
#define Curl_safefree(ptr) \
|
||||
do { free(ptr); (ptr) = NULL;} while(0)
|
||||
do { curlx_free(ptr); (ptr) = NULL;} while(0)
|
||||
|
||||
#include <curl/curl.h> /* for CURL_EXTERN, mprintf.h */
|
||||
|
||||
|
|
@ -1077,6 +1077,56 @@ CURL_EXTERN ALLOC_FUNC
|
|||
|
||||
#endif /* CURLDEBUG */
|
||||
|
||||
/* Allocator macros */
|
||||
|
||||
#ifdef CURLDEBUG
|
||||
|
||||
#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
|
||||
#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
|
||||
#define curlx_calloc(nbelem,size) \
|
||||
curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
|
||||
#define curlx_realloc(ptr,size) \
|
||||
curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
|
||||
#define curlx_free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef UNICODE
|
||||
#define curlx_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
|
||||
#else
|
||||
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#else /* !CURLDEBUG */
|
||||
|
||||
#ifdef BUILDING_LIBCURL
|
||||
#define curlx_strdup(ptr) Curl_cstrdup(ptr)
|
||||
#define curlx_malloc(size) Curl_cmalloc(size)
|
||||
#define curlx_calloc(nbelem,size) Curl_ccalloc(nbelem, size)
|
||||
#define curlx_realloc(ptr,size) Curl_crealloc(ptr, size)
|
||||
#define curlx_free(ptr) Curl_cfree(ptr)
|
||||
#else /* !BUILDING_LIBCURL */
|
||||
#ifdef _WIN32
|
||||
#define curlx_strdup(ptr) _strdup(ptr)
|
||||
#else
|
||||
#define curlx_strdup(ptr) strdup(ptr)
|
||||
#endif
|
||||
#define curlx_malloc(size) malloc(size)
|
||||
#define curlx_calloc(nbelem,size) calloc(nbelem, size)
|
||||
#define curlx_realloc(ptr,size) realloc(ptr, size)
|
||||
#define curlx_free(ptr) free(ptr)
|
||||
#endif /* BUILDING_LIBCURL */
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef UNICODE
|
||||
#define curlx_tcsdup(ptr) Curl_wcsdup(ptr)
|
||||
#else
|
||||
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* CURLDEBUG */
|
||||
|
||||
/* Some versions of the Android NDK is missing the declaration */
|
||||
#if defined(HAVE_GETPWUID_R) && \
|
||||
defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
|
||||
|
|
@ -1167,5 +1217,3 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
|
|||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_SETUP_H */
|
||||
|
||||
#include "curl_mem_undef.h"
|
||||
|
|
|
|||
|
|
@ -34,21 +34,17 @@
|
|||
#include "hsts.h"
|
||||
#include "url.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
CURLSH *
|
||||
curl_share_init(void)
|
||||
{
|
||||
struct Curl_share *share = calloc(1, sizeof(struct Curl_share));
|
||||
struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share));
|
||||
if(share) {
|
||||
share->magic = CURL_GOOD_SHARE;
|
||||
share->specifier |= (1 << CURL_LOCK_DATA_SHARE);
|
||||
Curl_dnscache_init(&share->dnscache, 23);
|
||||
share->admin = curl_easy_init();
|
||||
if(!share->admin) {
|
||||
free(share);
|
||||
curlx_free(share);
|
||||
return NULL;
|
||||
}
|
||||
/* admin handles have mid 0 */
|
||||
|
|
@ -272,7 +268,7 @@ curl_share_cleanup(CURLSH *sh)
|
|||
if(share->unlockfunc)
|
||||
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
||||
share->magic = 0;
|
||||
free(share);
|
||||
curlx_free(share);
|
||||
|
||||
return CURLSHE_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@
|
|||
#include "system_win32.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Pointer to SSPI dispatch table */
|
||||
PSecurityFunctionTable Curl_pSecFn = NULL;
|
||||
|
||||
|
|
@ -134,7 +130,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
|
|||
}
|
||||
|
||||
/* Setup the identity's user and length */
|
||||
dup_user.tchar_ptr = Curl_tcsdup(user.tchar_ptr);
|
||||
dup_user.tchar_ptr = curlx_tcsdup(user.tchar_ptr);
|
||||
if(!dup_user.tchar_ptr) {
|
||||
curlx_unicodefree(useranddomain.tchar_ptr);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -144,7 +140,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
|
|||
dup_user.tchar_ptr = NULL;
|
||||
|
||||
/* Setup the identity's domain and length */
|
||||
dup_domain.tchar_ptr = malloc(sizeof(TCHAR) * (domlen + 1));
|
||||
dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1));
|
||||
if(!dup_domain.tchar_ptr) {
|
||||
curlx_unicodefree(useranddomain.tchar_ptr);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -164,7 +160,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
|
|||
passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp);
|
||||
if(!passwd.tchar_ptr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
dup_passwd.tchar_ptr = Curl_tcsdup(passwd.tchar_ptr);
|
||||
dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr);
|
||||
if(!dup_passwd.tchar_ptr) {
|
||||
curlx_unicodefree(passwd.tchar_ptr);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@
|
|||
#endif
|
||||
|
||||
#include "curl_threads.h"
|
||||
#include "curl_memory.h"
|
||||
/* The last #include FILE should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef USE_THREADS_POSIX
|
||||
|
||||
|
|
@ -48,7 +45,7 @@ static void *curl_thread_create_thunk(void *arg)
|
|||
unsigned int (*func)(void *) = ac->func;
|
||||
void *real_arg = ac->arg;
|
||||
|
||||
free(ac);
|
||||
curlx_free(ac);
|
||||
|
||||
(*func)(real_arg);
|
||||
|
||||
|
|
@ -58,8 +55,8 @@ static void *curl_thread_create_thunk(void *arg)
|
|||
curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
|
||||
(CURL_STDCALL *func) (void *), void *arg)
|
||||
{
|
||||
curl_thread_t t = malloc(sizeof(pthread_t));
|
||||
struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call));
|
||||
curl_thread_t t = curlx_malloc(sizeof(pthread_t));
|
||||
struct Curl_actual_call *ac = curlx_malloc(sizeof(struct Curl_actual_call));
|
||||
int rc;
|
||||
if(!(ac && t))
|
||||
goto err;
|
||||
|
|
@ -76,8 +73,8 @@ curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
|
|||
return t;
|
||||
|
||||
err:
|
||||
free(t);
|
||||
free(ac);
|
||||
curlx_free(t);
|
||||
curlx_free(ac);
|
||||
return curl_thread_t_null;
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +82,7 @@ void Curl_thread_destroy(curl_thread_t *hnd)
|
|||
{
|
||||
if(*hnd != curl_thread_t_null) {
|
||||
pthread_detach(**hnd);
|
||||
free(*hnd);
|
||||
curlx_free(*hnd);
|
||||
*hnd = curl_thread_t_null;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +91,7 @@ int Curl_thread_join(curl_thread_t *hnd)
|
|||
{
|
||||
int ret = (pthread_join(**hnd, NULL) == 0);
|
||||
|
||||
free(*hnd);
|
||||
curlx_free(*hnd);
|
||||
*hnd = curl_thread_t_null;
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -47,10 +47,6 @@
|
|||
#include "vtls/vtls.h"
|
||||
#include "vquic/vquic.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static void trc_write(struct Curl_easy *data, curl_infotype type,
|
||||
const char *ptr, size_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,12 +30,6 @@
|
|||
#include "warnless.h"
|
||||
#include "base64.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#ifdef BUILDING_LIBCURL
|
||||
#include "../curl_memory.h"
|
||||
#endif
|
||||
#include "../memdebug.h"
|
||||
|
||||
/* ---- Base64 Encoding/Decoding Table --- */
|
||||
const char Curl_base64encdec[]=
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
|
@ -103,7 +97,7 @@ CURLcode curlx_base64_decode(const char *src,
|
|||
rawlen = (numQuantums * 3) - padding;
|
||||
|
||||
/* Allocate our buffer including room for a null-terminator */
|
||||
newstr = malloc(rawlen + 1);
|
||||
newstr = curlx_malloc(rawlen + 1);
|
||||
if(!newstr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -165,7 +159,7 @@ CURLcode curlx_base64_decode(const char *src,
|
|||
|
||||
return CURLE_OK;
|
||||
bad:
|
||||
free(newstr);
|
||||
curlx_free(newstr);
|
||||
return CURLE_BAD_CONTENT_ENCODING;
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +183,7 @@ static CURLcode base64_encode(const char *table64,
|
|||
if(insize > CURL_MAX_BASE64_INPUT)
|
||||
return CURLE_TOO_LARGE;
|
||||
|
||||
base64data = output = malloc((insize + 2) / 3 * 4 + 1);
|
||||
base64data = output = curlx_malloc((insize + 2) / 3 * 4 + 1);
|
||||
if(!output)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@
|
|||
#include "../curl_setup.h"
|
||||
#include "dynbuf.h"
|
||||
#include "../curl_printf.h"
|
||||
#ifdef BUILDING_LIBCURL
|
||||
#include "../curl_memory.h"
|
||||
#endif
|
||||
#include "../memdebug.h"
|
||||
|
||||
#define MIN_FIRST_ALLOC 32
|
||||
|
||||
|
|
@ -108,7 +104,7 @@ static CURLcode dyn_nappend(struct dynbuf *s,
|
|||
if(a != s->allc) {
|
||||
/* this logic is not using Curl_saferealloc() to make the tool not have to
|
||||
include that as well when it uses this code */
|
||||
void *p = realloc(s->bufr, a);
|
||||
void *p = curlx_realloc(s->bufr, a);
|
||||
if(!p) {
|
||||
curlx_dyn_free(s);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -212,7 +208,7 @@ CURLcode curlx_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
|
|||
|
||||
if(str) {
|
||||
CURLcode result = dyn_nappend(s, (const unsigned char *)str, strlen(str));
|
||||
free(str);
|
||||
curlx_free(str);
|
||||
return result;
|
||||
}
|
||||
/* If we failed, we cleanup the whole buffer and return error */
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) Danieal Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -23,11 +23,8 @@
|
|||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* This file is 'mem-include-scan' clean, which means its memory allocations
|
||||
* are not tracked by the curl memory tracker memdebug, so they must not use
|
||||
* `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid
|
||||
* these macro replacements, wrap the names in parentheses to call the original
|
||||
* versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc.
|
||||
* Use system allocators to avoid infinite recursion when called by curl's
|
||||
* memory tracker memdebug functions.
|
||||
*/
|
||||
|
||||
#include "../curl_setup.h"
|
||||
|
|
@ -103,7 +100,8 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
|
|||
goto cleanup;
|
||||
if(!needed || needed >= max_path_len)
|
||||
goto cleanup;
|
||||
ibuf = (malloc)(needed * sizeof(wchar_t));
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
ibuf = malloc(needed * sizeof(wchar_t));
|
||||
if(!ibuf)
|
||||
goto cleanup;
|
||||
if(mbstowcs_s(&count, ibuf, needed, in, needed - 1))
|
||||
|
|
@ -124,7 +122,8 @@ 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;
|
||||
fbuf = (malloc)(needed * sizeof(wchar_t));
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
fbuf = malloc(needed * sizeof(wchar_t));
|
||||
if(!fbuf)
|
||||
goto cleanup;
|
||||
count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL);
|
||||
|
|
@ -157,16 +156,19 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
|
|||
if(needed > max_path_len)
|
||||
goto cleanup;
|
||||
|
||||
temp = (malloc)(needed * sizeof(wchar_t));
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
temp = malloc(needed * sizeof(wchar_t));
|
||||
if(!temp)
|
||||
goto cleanup;
|
||||
|
||||
if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) {
|
||||
(free)(temp);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(temp);
|
||||
goto cleanup;
|
||||
}
|
||||
if(wcscpy_s(temp + 8, needed, fbuf + 2)) {
|
||||
(free)(temp);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(temp);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
|
@ -176,21 +178,25 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
|
|||
if(needed > max_path_len)
|
||||
goto cleanup;
|
||||
|
||||
temp = (malloc)(needed * sizeof(wchar_t));
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
temp = malloc(needed * sizeof(wchar_t));
|
||||
if(!temp)
|
||||
goto cleanup;
|
||||
|
||||
if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) {
|
||||
(free)(temp);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(temp);
|
||||
goto cleanup;
|
||||
}
|
||||
if(wcscpy_s(temp + 4, needed, fbuf)) {
|
||||
(free)(temp);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(temp);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
(free)(fbuf);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fbuf);
|
||||
fbuf = temp;
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +206,8 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
|
|||
goto cleanup;
|
||||
if(!needed || needed >= max_path_len)
|
||||
goto cleanup;
|
||||
obuf = (malloc)(needed);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
obuf = malloc(needed);
|
||||
if(!obuf)
|
||||
goto cleanup;
|
||||
if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1))
|
||||
|
|
@ -215,10 +222,12 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
|
|||
#endif
|
||||
|
||||
cleanup:
|
||||
(free)(fbuf);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fbuf);
|
||||
#ifndef _UNICODE
|
||||
(free)(ibuf);
|
||||
(free)(obuf);
|
||||
/* !checksrc! disable BANNEDFUNC 2 */
|
||||
free(ibuf);
|
||||
free(obuf);
|
||||
#endif
|
||||
return *out ? true : false;
|
||||
}
|
||||
|
|
@ -260,7 +269,8 @@ int curlx_win32_open(const char *filename, int oflag, ...)
|
|||
errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode);
|
||||
#endif
|
||||
|
||||
(free)(fixed);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fixed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +303,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
|
|||
errno = fopen_s(&result, target, mode);
|
||||
#endif
|
||||
|
||||
(free)(fixed);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fixed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +342,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp)
|
|||
errno = freopen_s(&result, target, mode, fp);
|
||||
#endif
|
||||
|
||||
(free)(fixed);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fixed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +382,8 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
(free)(fixed);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(fixed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,8 @@
|
|||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* This file is 'mem-include-scan' clean, which means its memory allocations
|
||||
* are not tracked by the curl memory tracker memdebug, so they must not use
|
||||
* `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid
|
||||
* these macro replacements, wrap the names in parentheses to call the original
|
||||
* versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc.
|
||||
* Use system allocators to avoid infinite recursion when called by curl's
|
||||
* memory tracker memdebug functions.
|
||||
*/
|
||||
|
||||
#include "../curl_setup.h"
|
||||
|
|
@ -48,11 +45,13 @@ 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 = (malloc)(str_w_len * sizeof(wchar_t));
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
str_w = malloc(str_w_len * sizeof(wchar_t));
|
||||
if(str_w) {
|
||||
if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
|
||||
str_w_len) == 0) {
|
||||
(free)(str_w);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(str_w);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -70,11 +69,13 @@ 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 = (malloc)(bytes);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
str_utf8 = malloc(bytes);
|
||||
if(str_utf8) {
|
||||
if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
|
||||
NULL, NULL) == 0) {
|
||||
(free)(str_utf8);
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
free(str_utf8);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,8 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
|
|||
*
|
||||
* Allocated memory should be free'd with curlx_unicodefree().
|
||||
*
|
||||
* Note: Because these are curlx functions their memory usage is not tracked
|
||||
* by the curl memory tracker memdebug. you will notice that curlx
|
||||
* function-like macros call free and strdup in parentheses, eg (strdup)(ptr),
|
||||
* and that is to ensure that the curl memdebug override macros do not replace
|
||||
* them.
|
||||
* Use system allocators to avoid infinite recursion when called by curl's
|
||||
* memory tracker memdebug functions.
|
||||
*/
|
||||
|
||||
#if defined(UNICODE) && defined(_WIN32)
|
||||
|
|
@ -65,8 +62,13 @@ typedef union {
|
|||
|
||||
#else
|
||||
|
||||
#define curlx_convert_UTF8_to_tchar(ptr) (strdup)(ptr)
|
||||
#define curlx_convert_tchar_to_UTF8(ptr) (strdup)(ptr)
|
||||
#ifdef _WIN32
|
||||
#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) strdup(ptr)
|
||||
#define curlx_convert_tchar_to_UTF8(ptr) strdup(ptr)
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
char *tchar_ptr;
|
||||
|
|
@ -78,6 +80,6 @@ typedef union {
|
|||
#endif /* UNICODE && _WIN32 */
|
||||
|
||||
/* the purpose of this macro is to free() without being traced by memdebug */
|
||||
#define curlx_unicodefree(ptr) (free)(ptr)
|
||||
#define curlx_unicodefree(ptr) free(ptr)
|
||||
|
||||
#endif /* HEADER_CURL_MULTIBYTE_H */
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@
|
|||
#include "winapi.h"
|
||||
#include "snprintf.h"
|
||||
#include "strerr.h"
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "../curl_memory.h"
|
||||
#include "../memdebug.h"
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
/* This is a helper function for curlx_strerror that converts Winsock error
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@
|
|||
#include "version_win32.h"
|
||||
#include "warnless.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "../curl_memory.h"
|
||||
#include "../memdebug.h"
|
||||
|
||||
/* This Unicode version struct works for VerifyVersionInfoW (OSVERSIONINFOEXW)
|
||||
and RtlVerifyVersionInfo (RTLOSVERSIONINFOEXW) */
|
||||
struct OUR_OSVERSIONINFOEXW {
|
||||
|
|
|
|||
|
|
@ -35,10 +35,6 @@
|
|||
#include "cw-out.h"
|
||||
#include "cw-pause.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
/**
|
||||
* OVERALL DESIGN of this client writer
|
||||
|
|
@ -85,7 +81,7 @@ struct cw_out_buf {
|
|||
|
||||
static struct cw_out_buf *cw_out_buf_create(cw_out_type otype)
|
||||
{
|
||||
struct cw_out_buf *cwbuf = calloc(1, sizeof(*cwbuf));
|
||||
struct cw_out_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf));
|
||||
if(cwbuf) {
|
||||
cwbuf->type = otype;
|
||||
curlx_dyn_init(&cwbuf->b, DYN_PAUSE_BUFFER);
|
||||
|
|
@ -97,7 +93,7 @@ static void cw_out_buf_free(struct cw_out_buf *cwbuf)
|
|||
{
|
||||
if(cwbuf) {
|
||||
curlx_dyn_free(&cwbuf->b);
|
||||
free(cwbuf);
|
||||
curlx_free(cwbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@
|
|||
#include "sendf.h"
|
||||
#include "cw-pause.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
/* body dynbuf sizes */
|
||||
#define CW_PAUSE_BUF_CHUNK (16 * 1024)
|
||||
|
|
@ -52,7 +48,7 @@ struct cw_pause_buf {
|
|||
|
||||
static struct cw_pause_buf *cw_pause_buf_create(int type, size_t buflen)
|
||||
{
|
||||
struct cw_pause_buf *cwbuf = calloc(1, sizeof(*cwbuf));
|
||||
struct cw_pause_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf));
|
||||
if(cwbuf) {
|
||||
cwbuf->type = type;
|
||||
if(type & CLIENTWRITE_BODY)
|
||||
|
|
@ -68,7 +64,7 @@ static void cw_pause_buf_free(struct cw_pause_buf *cwbuf)
|
|||
{
|
||||
if(cwbuf) {
|
||||
Curl_bufq_free(&cwbuf->b);
|
||||
free(cwbuf);
|
||||
curlx_free(cwbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
11
lib/dict.c
11
lib/dict.c
|
|
@ -60,11 +60,6 @@
|
|||
#include "progress.h"
|
||||
#include "dict.h"
|
||||
|
||||
/* The last 2 #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#define DICT_MATCH "/MATCH:"
|
||||
#define DICT_MATCH2 "/M:"
|
||||
#define DICT_MATCH3 "/FIND:"
|
||||
|
|
@ -172,7 +167,7 @@ static CURLcode sendf(struct Curl_easy *data, const char *fmt, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
free(s); /* free the output string */
|
||||
curlx_free(s); /* free the output string */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -310,8 +305,8 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done)
|
|||
}
|
||||
|
||||
error:
|
||||
free(eword);
|
||||
free(path);
|
||||
curlx_free(eword);
|
||||
curlx_free(path);
|
||||
return result;
|
||||
}
|
||||
#endif /* CURL_DISABLE_DICT */
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@
|
|||
#include <openssl/crypto.h>
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* DllMain() must only be defined for Windows DLL builds. */
|
||||
#if defined(_WIN32) && !defined(CURL_STATICLIB)
|
||||
|
||||
|
|
|
|||
18
lib/doh.c
18
lib/doh.c
|
|
@ -41,10 +41,6 @@
|
|||
#include "escape.h"
|
||||
#include "urlapi-int.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define DNS_CLASS_IN 0x01
|
||||
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
|
|
@ -269,7 +265,7 @@ static void doh_probe_dtor(void *key, size_t klen, void *e)
|
|||
struct doh_request *doh_req = e;
|
||||
curl_slist_free_all(doh_req->req_hds);
|
||||
curlx_dyn_free(&doh_req->resp_body);
|
||||
free(e);
|
||||
curlx_free(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +292,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data,
|
|||
|
||||
*pmid = UINT32_MAX;
|
||||
|
||||
doh_req = calloc(1, sizeof(*doh_req));
|
||||
doh_req = curlx_calloc(1, sizeof(*doh_req));
|
||||
if(!doh_req)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
doh_req->dnstype = dnstype;
|
||||
|
|
@ -462,12 +458,12 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname,
|
|||
data->state.async.done = FALSE;
|
||||
data->state.async.port = port;
|
||||
data->state.async.ip_version = ip_version;
|
||||
data->state.async.hostname = strdup(hostname);
|
||||
data->state.async.hostname = curlx_strdup(hostname);
|
||||
if(!data->state.async.hostname)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* start clean, consider allocating this struct on demand */
|
||||
data->state.async.doh = dohp = calloc(1, sizeof(struct doh_probes));
|
||||
data->state.async.doh = dohp = curlx_calloc(1, sizeof(struct doh_probes));
|
||||
if(!dohp)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -518,7 +514,7 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname,
|
|||
qname ? qname : hostname, data->set.str[STRING_DOH],
|
||||
data->multi,
|
||||
&dohp->probe_resp[DOH_SLOT_HTTPS_RR].probe_mid);
|
||||
free(qname);
|
||||
curlx_free(qname);
|
||||
if(result)
|
||||
goto error;
|
||||
dohp->pending++;
|
||||
|
|
@ -963,7 +959,7 @@ static CURLcode doh2ai(const struct dohentry *de, const char *hostname,
|
|||
addrtype = AF_INET;
|
||||
}
|
||||
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
|
||||
ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
|
||||
if(!ai) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
@ -1130,7 +1126,7 @@ UNITTEST CURLcode doh_resp_decode_httpsrr(struct Curl_easy *data,
|
|||
*hrr = NULL;
|
||||
if(len <= 2)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
lhrr = calloc(1, sizeof(struct Curl_https_rrinfo));
|
||||
lhrr = curlx_calloc(1, sizeof(struct Curl_https_rrinfo));
|
||||
if(!lhrr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
lhrr->priority = doh_get16bit(cp, 0);
|
||||
|
|
|
|||
14
lib/dynhds.c
14
lib/dynhds.c
|
|
@ -31,10 +31,6 @@
|
|||
#include <nghttp2/nghttp2.h>
|
||||
#endif /* USE_NGHTTP2 */
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
static struct dynhds_entry *
|
||||
entry_new(const char *name, size_t namelen,
|
||||
|
|
@ -45,7 +41,7 @@ entry_new(const char *name, size_t namelen,
|
|||
|
||||
DEBUGASSERT(name);
|
||||
DEBUGASSERT(value);
|
||||
e = calloc(1, sizeof(*e) + namelen + valuelen + 2);
|
||||
e = curlx_calloc(1, sizeof(*e) + namelen + valuelen + 2);
|
||||
if(!e)
|
||||
return NULL;
|
||||
e->name = p = ((char *)e) + sizeof(*e);
|
||||
|
|
@ -68,7 +64,7 @@ entry_append(struct dynhds_entry *e,
|
|||
char *p;
|
||||
|
||||
DEBUGASSERT(value);
|
||||
e2 = calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2);
|
||||
e2 = curlx_calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2);
|
||||
if(!e2)
|
||||
return NULL;
|
||||
e2->name = p = ((char *)e2) + sizeof(*e2);
|
||||
|
|
@ -85,7 +81,7 @@ entry_append(struct dynhds_entry *e,
|
|||
|
||||
static void entry_free(struct dynhds_entry *e)
|
||||
{
|
||||
free(e);
|
||||
curlx_free(e);
|
||||
}
|
||||
|
||||
void Curl_dynhds_init(struct dynhds *dynhds, size_t max_entries,
|
||||
|
|
@ -186,7 +182,7 @@ entry = entry_new(name, namelen, value, valuelen, dynhds->opts);
|
|||
if(dynhds->max_entries && nallc > dynhds->max_entries)
|
||||
nallc = dynhds->max_entries;
|
||||
|
||||
nhds = calloc(nallc, sizeof(struct dynhds_entry *));
|
||||
nhds = curlx_calloc(nallc, sizeof(struct dynhds_entry *));
|
||||
if(!nhds)
|
||||
goto out;
|
||||
if(dynhds->hds) {
|
||||
|
|
@ -374,7 +370,7 @@ CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf)
|
|||
|
||||
nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount)
|
||||
{
|
||||
nghttp2_nv *nva = calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len);
|
||||
nghttp2_nv *nva = curlx_calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len);
|
||||
size_t i;
|
||||
|
||||
*pcount = 0;
|
||||
|
|
|
|||
24
lib/easy.c
24
lib/easy.c
|
|
@ -80,10 +80,6 @@
|
|||
|
||||
#include "easy_lock.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* true globals -- for curl_global_init() and curl_global_cleanup() */
|
||||
static unsigned int initialized;
|
||||
static long easy_init_flags;
|
||||
|
|
@ -198,7 +194,7 @@ static CURLcode global_init(long flags, bool memoryfuncs)
|
|||
#ifdef DEBUGBUILD
|
||||
if(getenv("CURL_GLOBAL_INIT"))
|
||||
/* alloc data that will leak if *cleanup() is not called! */
|
||||
leakpointer = malloc(1);
|
||||
leakpointer = curlx_malloc(1);
|
||||
#endif
|
||||
|
||||
return CURLE_OK;
|
||||
|
|
@ -297,7 +293,7 @@ void curl_global_cleanup(void)
|
|||
Curl_ssh_cleanup();
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
free(leakpointer);
|
||||
curlx_free(leakpointer);
|
||||
#endif
|
||||
|
||||
easy_init_flags = 0;
|
||||
|
|
@ -478,7 +474,7 @@ static int events_socket(CURL *easy, /* easy handle */
|
|||
prev->next = nxt;
|
||||
else
|
||||
ev->list = nxt;
|
||||
free(m);
|
||||
curlx_free(m);
|
||||
infof(data, "socket cb: socket %" FMT_SOCKET_T " REMOVED", s);
|
||||
}
|
||||
else {
|
||||
|
|
@ -504,7 +500,7 @@ static int events_socket(CURL *easy, /* easy handle */
|
|||
DEBUGASSERT(0);
|
||||
}
|
||||
else {
|
||||
m = malloc(sizeof(struct socketmonitor));
|
||||
m = curlx_malloc(sizeof(struct socketmonitor));
|
||||
if(m) {
|
||||
m->next = ev->list;
|
||||
m->socket.fd = s;
|
||||
|
|
@ -927,7 +923,7 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
|
|||
i = STRING_COPYPOSTFIELDS;
|
||||
if(src->set.str[i]) {
|
||||
if(src->set.postfieldsize == -1)
|
||||
dst->set.str[i] = strdup(src->set.str[i]);
|
||||
dst->set.str[i] = curlx_strdup(src->set.str[i]);
|
||||
else
|
||||
/* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
|
||||
dst->set.str[i] = Curl_memdup(src->set.str[i],
|
||||
|
|
@ -968,7 +964,7 @@ CURL *curl_easy_duphandle(CURL *d)
|
|||
|
||||
if(!GOOD_EASY_HANDLE(data))
|
||||
goto fail;
|
||||
outcurl = calloc(1, sizeof(struct Curl_easy));
|
||||
outcurl = curlx_calloc(1, sizeof(struct Curl_easy));
|
||||
if(!outcurl)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -1022,14 +1018,14 @@ CURL *curl_easy_duphandle(CURL *d)
|
|||
#endif
|
||||
|
||||
if(data->state.url) {
|
||||
outcurl->state.url = strdup(data->state.url);
|
||||
outcurl->state.url = curlx_strdup(data->state.url);
|
||||
if(!outcurl->state.url)
|
||||
goto fail;
|
||||
outcurl->state.url_alloc = TRUE;
|
||||
}
|
||||
|
||||
if(data->state.referer) {
|
||||
outcurl->state.referer = strdup(data->state.referer);
|
||||
outcurl->state.referer = curlx_strdup(data->state.referer);
|
||||
if(!outcurl->state.referer)
|
||||
goto fail;
|
||||
outcurl->state.referer_alloc = TRUE;
|
||||
|
|
@ -1073,13 +1069,13 @@ fail:
|
|||
|
||||
if(outcurl) {
|
||||
#ifndef CURL_DISABLE_COOKIES
|
||||
free(outcurl->cookies);
|
||||
curlx_free(outcurl->cookies);
|
||||
#endif
|
||||
curlx_dyn_free(&outcurl->state.headerb);
|
||||
Curl_altsvc_cleanup(&outcurl->asi);
|
||||
Curl_hsts_cleanup(&outcurl->hsts);
|
||||
Curl_freeset(outcurl);
|
||||
free(outcurl);
|
||||
curlx_free(outcurl);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
10
lib/escape.c
10
lib/escape.c
|
|
@ -37,10 +37,6 @@ struct Curl_easy;
|
|||
#include "curlx/strparse.h"
|
||||
#include "curl_printf.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* for ABI-compatibility with previous versions */
|
||||
char *curl_escape(const char *string, int inlength)
|
||||
{
|
||||
|
|
@ -68,7 +64,7 @@ char *curl_easy_escape(CURL *data, const char *string,
|
|||
|
||||
length = (inlength ? (size_t)inlength : strlen(string));
|
||||
if(!length)
|
||||
return strdup("");
|
||||
return curlx_strdup("");
|
||||
|
||||
curlx_dyn_init(&d, length * 3 + 1);
|
||||
|
||||
|
|
@ -120,7 +116,7 @@ CURLcode Curl_urldecode(const char *string, size_t length,
|
|||
DEBUGASSERT(ctrl >= REJECT_NADA); /* crash on TRUE/FALSE */
|
||||
|
||||
alloc = (length ? length : strlen(string));
|
||||
ns = malloc(alloc + 1);
|
||||
ns = curlx_malloc(alloc + 1);
|
||||
|
||||
if(!ns)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -196,7 +192,7 @@ char *curl_easy_unescape(CURL *data, const char *string,
|
|||
the library's memory system */
|
||||
void curl_free(void *p)
|
||||
{
|
||||
free(p);
|
||||
curlx_free(p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <ares.h>
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
void r_freeaddrinfo(struct addrinfo *cahead)
|
||||
{
|
||||
struct addrinfo *canext;
|
||||
|
|
@ -42,7 +38,7 @@ void r_freeaddrinfo(struct addrinfo *cahead)
|
|||
|
||||
for(ca = cahead; ca; ca = canext) {
|
||||
canext = ca->ai_next;
|
||||
free(ca);
|
||||
curlx_free(ca);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +86,7 @@ static struct addrinfo *mk_getaddrinfo(const struct ares_addrinfo *aihead)
|
|||
if((size_t)ai->ai_addrlen < ss_size)
|
||||
continue;
|
||||
|
||||
ca = malloc(sizeof(struct addrinfo) + ss_size + namelen);
|
||||
ca = curlx_malloc(sizeof(struct addrinfo) + ss_size + namelen);
|
||||
if(!ca) {
|
||||
r_freeaddrinfo(cafirst);
|
||||
return NULL;
|
||||
|
|
|
|||
10
lib/file.c
10
lib/file.c
|
|
@ -68,10 +68,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "curl_range.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(_WIN32) || defined(MSDOS)
|
||||
#define DOS_FILESYSTEM 1
|
||||
#elif defined(__amigaos4__)
|
||||
|
|
@ -148,7 +144,7 @@ static void file_easy_dtor(void *key, size_t klen, void *entry)
|
|||
(void)key;
|
||||
(void)klen;
|
||||
file_cleanup(file);
|
||||
free(file);
|
||||
curlx_free(file);
|
||||
}
|
||||
|
||||
static CURLcode file_setup_connection(struct Curl_easy *data,
|
||||
|
|
@ -157,7 +153,7 @@ static CURLcode file_setup_connection(struct Curl_easy *data,
|
|||
struct FILEPROTO *filep;
|
||||
(void)conn;
|
||||
/* allocate the FILE specific struct */
|
||||
filep = calloc(1, sizeof(*filep));
|
||||
filep = curlx_calloc(1, sizeof(*filep));
|
||||
if(!filep ||
|
||||
Curl_meta_set(data, CURL_META_FILE_EASY, filep, file_easy_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -269,7 +265,7 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
|
|||
file->path = real_path;
|
||||
#endif
|
||||
#endif
|
||||
free(file->freepath);
|
||||
curlx_free(file->freepath);
|
||||
file->freepath = real_path; /* free this when done */
|
||||
|
||||
file->fd = fd;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,10 @@
|
|||
#ifndef CURL_DISABLE_FTP
|
||||
|
||||
#include "fileinfo.h"
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
struct fileinfo *Curl_fileinfo_alloc(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct fileinfo));
|
||||
return curlx_calloc(1, sizeof(struct fileinfo));
|
||||
}
|
||||
|
||||
void Curl_fileinfo_cleanup(struct fileinfo *finfo)
|
||||
|
|
@ -42,7 +39,7 @@ void Curl_fileinfo_cleanup(struct fileinfo *finfo)
|
|||
return;
|
||||
|
||||
curlx_dyn_free(&finfo->buf);
|
||||
free(finfo);
|
||||
curlx_free(finfo);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@ struct Curl_easy;
|
|||
#include "curlx/fopen.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME
|
||||
#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME
|
||||
|
|
@ -76,7 +72,7 @@ AddHttpPost(struct FormInfo *src,
|
|||
if((src->bufferlength > LONG_MAX) || (namelength > LONG_MAX))
|
||||
/* avoid overflow in typecasts below */
|
||||
return NULL;
|
||||
post = calloc(1, sizeof(struct curl_httppost));
|
||||
post = curlx_calloc(1, sizeof(struct curl_httppost));
|
||||
if(post) {
|
||||
post->name = src->name;
|
||||
post->namelength = (long)namelength;
|
||||
|
|
@ -127,7 +123,7 @@ static struct FormInfo *AddFormInfo(char *value,
|
|||
struct FormInfo *parent_form_info)
|
||||
{
|
||||
struct FormInfo *form_info;
|
||||
form_info = calloc(1, sizeof(struct FormInfo));
|
||||
form_info = curlx_calloc(1, sizeof(struct FormInfo));
|
||||
if(!form_info)
|
||||
return NULL;
|
||||
if(value)
|
||||
|
|
@ -262,7 +258,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form,
|
|||
type = FILE_CONTENTTYPE_DEFAULT;
|
||||
|
||||
/* our contenttype is missing */
|
||||
form->contenttype = strdup(type);
|
||||
form->contenttype = curlx_strdup(type);
|
||||
if(!form->contenttype)
|
||||
return CURL_FORMADD_MEMORY;
|
||||
|
||||
|
|
@ -320,7 +316,7 @@ static void free_chain(struct curl_httppost *c)
|
|||
struct curl_httppost *next = c->next;
|
||||
if(c->more)
|
||||
free_chain(c->more);
|
||||
free(c);
|
||||
curlx_free(c);
|
||||
c = next;
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +342,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
/*
|
||||
* We need to allocate the first struct to fill in.
|
||||
*/
|
||||
first_form = calloc(1, sizeof(struct FormInfo));
|
||||
first_form = curlx_calloc(1, sizeof(struct FormInfo));
|
||||
if(!first_form)
|
||||
return CURL_FORMADD_MEMORY;
|
||||
|
||||
|
|
@ -458,7 +454,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
if(!array_state)
|
||||
avalue = va_arg(params, char *);
|
||||
if(avalue) {
|
||||
curr->value = strdup(avalue);
|
||||
curr->value = curlx_strdup(avalue);
|
||||
if(!curr->value)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else {
|
||||
|
|
@ -479,13 +475,13 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
if(curr->value) {
|
||||
if(curr->flags & HTTPPOST_FILENAME) {
|
||||
if(avalue) {
|
||||
char *fname = strdup(avalue);
|
||||
char *fname = curlx_strdup(avalue);
|
||||
if(!fname)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else {
|
||||
form = AddFormInfo(fname, NULL, curr);
|
||||
if(!form) {
|
||||
free(fname);
|
||||
curlx_free(fname);
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
}
|
||||
else {
|
||||
|
|
@ -503,7 +499,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
}
|
||||
else {
|
||||
if(avalue) {
|
||||
curr->value = strdup(avalue);
|
||||
curr->value = curlx_strdup(avalue);
|
||||
if(!curr->value)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else {
|
||||
|
|
@ -566,13 +562,13 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
if(curr->contenttype) {
|
||||
if(curr->flags & HTTPPOST_FILENAME) {
|
||||
if(avalue) {
|
||||
char *type = strdup(avalue);
|
||||
char *type = curlx_strdup(avalue);
|
||||
if(!type)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else {
|
||||
form = AddFormInfo(NULL, type, curr);
|
||||
if(!form) {
|
||||
free(type);
|
||||
curlx_free(type);
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
}
|
||||
else {
|
||||
|
|
@ -590,7 +586,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
}
|
||||
else {
|
||||
if(avalue) {
|
||||
curr->contenttype = strdup(avalue);
|
||||
curr->contenttype = curlx_strdup(avalue);
|
||||
if(!curr->contenttype)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else
|
||||
|
|
@ -623,7 +619,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
if(curr->showfilename)
|
||||
retval = CURL_FORMADD_OPTION_TWICE;
|
||||
else {
|
||||
curr->showfilename = strdup(avalue);
|
||||
curr->showfilename = curlx_strdup(avalue);
|
||||
if(!curr->showfilename)
|
||||
retval = CURL_FORMADD_MEMORY;
|
||||
else
|
||||
|
|
@ -650,7 +646,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
now by the httppost linked list */
|
||||
while(first_form) {
|
||||
struct FormInfo *ptr = first_form->more;
|
||||
free(first_form);
|
||||
curlx_free(first_form);
|
||||
first_form = ptr;
|
||||
}
|
||||
|
||||
|
|
@ -743,14 +739,14 @@ void curl_formfree(struct curl_httppost *form)
|
|||
curl_formfree(form->more);
|
||||
|
||||
if(!(form->flags & HTTPPOST_PTRNAME))
|
||||
free(form->name); /* free the name */
|
||||
curlx_free(form->name); /* free the name */
|
||||
if(!(form->flags &
|
||||
(HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK))
|
||||
)
|
||||
free(form->contents); /* free the contents */
|
||||
free(form->contenttype); /* free the content type */
|
||||
free(form->showfilename); /* free the faked filename */
|
||||
free(form); /* free the struct */
|
||||
curlx_free(form->contents); /* free the contents */
|
||||
curlx_free(form->contenttype); /* free the content type */
|
||||
curlx_free(form->showfilename); /* free the faked filename */
|
||||
curlx_free(form); /* free the struct */
|
||||
form = next;
|
||||
} while(form); /* continue */
|
||||
}
|
||||
|
|
@ -768,7 +764,7 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len)
|
|||
if(!zname)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
res = curl_mime_name(part, zname);
|
||||
free(zname);
|
||||
curlx_free(zname);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
68
lib/ftp.c
68
lib/ftp.c
|
|
@ -72,10 +72,6 @@
|
|||
#include "curlx/strerr.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#endif
|
||||
|
|
@ -1419,7 +1415,7 @@ static CURLcode ftp_state_list(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd);
|
||||
free(cmd);
|
||||
curlx_free(cmd);
|
||||
|
||||
if(!result)
|
||||
ftp_state(data, ftpc, FTP_LIST);
|
||||
|
|
@ -1770,12 +1766,12 @@ static CURLcode ftp_control_addr_dup(struct Curl_easy *data,
|
|||
not the ftp host. */
|
||||
#ifndef CURL_DISABLE_PROXY
|
||||
if(conn->bits.tunnel_proxy || conn->bits.socksproxy)
|
||||
*newhostp = strdup(conn->host.name);
|
||||
*newhostp = curlx_strdup(conn->host.name);
|
||||
else
|
||||
#endif
|
||||
if(!Curl_conn_get_ip_info(data, conn, FIRSTSOCKET, &is_ipv6, &ipquad) &&
|
||||
*ipquad.remote_ip)
|
||||
*newhostp = strdup(ipquad.remote_ip);
|
||||
*newhostp = curlx_strdup(ipquad.remote_ip);
|
||||
else {
|
||||
/* failed to get the remote_ip of the DATA connection */
|
||||
failf(data, "unable to get peername of DATA connection");
|
||||
|
|
@ -1934,7 +1930,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
|
|||
|
||||
/* postponed address resolution in case of tcp fastopen */
|
||||
if(conn->bits.tcp_fastopen && !conn->bits.reuse && !newhost[0]) {
|
||||
free(newhost);
|
||||
curlx_free(newhost);
|
||||
result = ftp_control_addr_dup(data, &newhost);
|
||||
if(result)
|
||||
goto error;
|
||||
|
|
@ -1956,7 +1952,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
|
|||
|
||||
if(result) {
|
||||
if(ftpc->count1 == 0 && ftpcode == 229) {
|
||||
free(newhost);
|
||||
curlx_free(newhost);
|
||||
return ftp_epsv_disable(data, ftpc, conn);
|
||||
}
|
||||
|
||||
|
|
@ -1973,9 +1969,9 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
|
|||
/* this just dumps information about this second connection */
|
||||
ftp_pasv_verbose(data, dns->addr, newhost, connectport);
|
||||
|
||||
free(conn->secondaryhostname);
|
||||
curlx_free(conn->secondaryhostname);
|
||||
conn->secondary_port = newport;
|
||||
conn->secondaryhostname = strdup(newhost);
|
||||
conn->secondaryhostname = curlx_strdup(newhost);
|
||||
if(!conn->secondaryhostname) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
|
|
@ -1985,7 +1981,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
|
|||
ftp_state(data, ftpc, FTP_STOP); /* this phase is completed */
|
||||
|
||||
error:
|
||||
free(newhost);
|
||||
curlx_free(newhost);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -2723,17 +2719,17 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data,
|
|||
if(!ftpc->server_os && dir[0] != '/') {
|
||||
result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SYST");
|
||||
if(result) {
|
||||
free(dir);
|
||||
curlx_free(dir);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
free(ftpc->entrypath);
|
||||
curlx_free(ftpc->entrypath);
|
||||
ftpc->entrypath = dir; /* remember this */
|
||||
infof(data, "Entry path is '%s'", ftpc->entrypath);
|
||||
/* also save it where getinfo can access it: */
|
||||
free(data->state.most_recent_ftp_entrypath);
|
||||
data->state.most_recent_ftp_entrypath = strdup(ftpc->entrypath);
|
||||
curlx_free(data->state.most_recent_ftp_entrypath);
|
||||
data->state.most_recent_ftp_entrypath = curlx_strdup(ftpc->entrypath);
|
||||
if(!data->state.most_recent_ftp_entrypath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -2961,18 +2957,18 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data,
|
|||
/* Force OS400 name format 1. */
|
||||
result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SITE NAMEFMT 1");
|
||||
if(result) {
|
||||
free(os);
|
||||
curlx_free(os);
|
||||
return result;
|
||||
}
|
||||
/* remember target server OS */
|
||||
free(ftpc->server_os);
|
||||
curlx_free(ftpc->server_os);
|
||||
ftpc->server_os = os;
|
||||
ftp_state(data, ftpc, FTP_NAMEFMT);
|
||||
break;
|
||||
}
|
||||
/* Nothing special for the target server. */
|
||||
/* remember target server OS */
|
||||
free(ftpc->server_os);
|
||||
curlx_free(ftpc->server_os);
|
||||
ftpc->server_os = os;
|
||||
}
|
||||
else {
|
||||
|
|
@ -3277,7 +3273,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
|
|||
* the error path) */
|
||||
ftpc->ctl_valid = FALSE; /* mark control connection as bad */
|
||||
connclose(conn, "FTP: out of memory!"); /* mark for connection closure */
|
||||
free(ftpc->prevpath);
|
||||
curlx_free(ftpc->prevpath);
|
||||
ftpc->prevpath = NULL; /* no path remembering */
|
||||
}
|
||||
else { /* remember working directory for connection reuse */
|
||||
|
|
@ -3288,7 +3284,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
|
|||
else {
|
||||
size_t pathLen = strlen(ftpc->rawpath);
|
||||
|
||||
free(ftpc->prevpath);
|
||||
curlx_free(ftpc->prevpath);
|
||||
|
||||
if(!ftpc->cwdfail) {
|
||||
if(data->set.ftp_filemethod == FTPFILE_NOCWD)
|
||||
|
|
@ -3757,7 +3753,7 @@ static void wc_data_dtor(void *ptr)
|
|||
struct ftp_wc *ftpwc = ptr;
|
||||
if(ftpwc && ftpwc->parser)
|
||||
Curl_ftp_parselist_data_free(&ftpwc->parser);
|
||||
free(ftpwc);
|
||||
curlx_free(ftpwc);
|
||||
}
|
||||
|
||||
static CURLcode init_wc_data(struct Curl_easy *data,
|
||||
|
|
@ -3777,14 +3773,14 @@ static CURLcode init_wc_data(struct Curl_easy *data,
|
|||
wildcard->state = CURLWC_CLEAN;
|
||||
return ftp_parse_url_path(data, ftpc, ftp);
|
||||
}
|
||||
wildcard->pattern = strdup(last_slash);
|
||||
wildcard->pattern = curlx_strdup(last_slash);
|
||||
if(!wildcard->pattern)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
last_slash[0] = '\0'; /* cut file from path */
|
||||
}
|
||||
else { /* there is only 'wildcard pattern' or nothing */
|
||||
if(path[0]) {
|
||||
wildcard->pattern = strdup(path);
|
||||
wildcard->pattern = curlx_strdup(path);
|
||||
if(!wildcard->pattern)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
path[0] = '\0';
|
||||
|
|
@ -3799,7 +3795,7 @@ static CURLcode init_wc_data(struct Curl_easy *data,
|
|||
resources for wildcard transfer */
|
||||
|
||||
/* allocate ftp protocol specific wildcard data */
|
||||
ftpwc = calloc(1, sizeof(struct ftp_wc));
|
||||
ftpwc = curlx_calloc(1, sizeof(struct ftp_wc));
|
||||
if(!ftpwc) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -3825,7 +3821,7 @@ static CURLcode init_wc_data(struct Curl_easy *data,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
wildcard->path = strdup(ftp->path);
|
||||
wildcard->path = curlx_strdup(ftp->path);
|
||||
if(!wildcard->path) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -3846,7 +3842,7 @@ static CURLcode init_wc_data(struct Curl_easy *data,
|
|||
fail:
|
||||
if(ftpwc) {
|
||||
Curl_ftp_parselist_data_free(&ftpwc->parser);
|
||||
free(ftpwc);
|
||||
curlx_free(ftpwc);
|
||||
}
|
||||
Curl_safefree(wildcard->pattern);
|
||||
wildcard->dtor = ZERO_NULL;
|
||||
|
|
@ -3904,7 +3900,7 @@ static CURLcode wc_statemach(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* switch default ftp->path and tmp_path */
|
||||
free(ftp->pathalloc);
|
||||
curlx_free(ftp->pathalloc);
|
||||
ftp->pathalloc = ftp->path = tmp_path;
|
||||
|
||||
infof(data, "Wildcard - START of \"%s\"", finfo->filename);
|
||||
|
|
@ -4179,7 +4175,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data,
|
|||
if(dirlen == 0)
|
||||
dirlen = 1;
|
||||
|
||||
ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
|
||||
ftpc->dirs = curlx_calloc(1, sizeof(ftpc->dirs[0]));
|
||||
if(!ftpc->dirs)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -4205,7 +4201,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data,
|
|||
return CURLE_URL_MALFORMAT;
|
||||
|
||||
if(dirAlloc) {
|
||||
ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
|
||||
ftpc->dirs = curlx_calloc(dirAlloc, sizeof(ftpc->dirs[0]));
|
||||
if(!ftpc->dirs)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -4372,7 +4368,7 @@ static void ftp_easy_dtor(void *key, size_t klen, void *entry)
|
|||
(void)key;
|
||||
(void)klen;
|
||||
Curl_safefree(ftp->pathalloc);
|
||||
free(ftp);
|
||||
curlx_free(ftp);
|
||||
}
|
||||
|
||||
static void ftp_conn_dtor(void *key, size_t klen, void *entry)
|
||||
|
|
@ -4387,7 +4383,7 @@ static void ftp_conn_dtor(void *key, size_t klen, void *entry)
|
|||
Curl_safefree(ftpc->prevpath);
|
||||
Curl_safefree(ftpc->server_os);
|
||||
Curl_pp_disconnect(&ftpc->pp);
|
||||
free(ftpc);
|
||||
curlx_free(ftpc);
|
||||
}
|
||||
|
||||
static void type_url_check(struct Curl_easy *data, struct FTP *ftp)
|
||||
|
|
@ -4426,19 +4422,19 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,
|
|||
CURLcode result = CURLE_OK;
|
||||
struct ftp_conn *ftpc;
|
||||
|
||||
ftp = calloc(1, sizeof(*ftp));
|
||||
ftp = curlx_calloc(1, sizeof(*ftp));
|
||||
if(!ftp ||
|
||||
Curl_meta_set(data, CURL_META_FTP_EASY, ftp, ftp_easy_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
ftpc = calloc(1, sizeof(*ftpc));
|
||||
ftpc = curlx_calloc(1, sizeof(*ftpc));
|
||||
if(!ftpc ||
|
||||
Curl_conn_meta_set(conn, CURL_META_FTP_CONN, ftpc, ftp_conn_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* clone connection related data that is FTP specific */
|
||||
if(data->set.str[STRING_FTP_ACCOUNT]) {
|
||||
ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]);
|
||||
ftpc->account = curlx_strdup(data->set.str[STRING_FTP_ACCOUNT]);
|
||||
if(!ftpc->account) {
|
||||
Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -4446,7 +4442,7 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,
|
|||
}
|
||||
if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]) {
|
||||
ftpc->alternative_to_user =
|
||||
strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
|
||||
curlx_strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
|
||||
if(!ftpc->alternative_to_user) {
|
||||
Curl_safefree(ftpc->account);
|
||||
Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@
|
|||
#include "multiif.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef enum {
|
||||
PL_UNIX_TOTALSIZE = 0,
|
||||
PL_UNIX_FILETYPE,
|
||||
|
|
@ -205,18 +201,18 @@ void Curl_wildcard_dtor(struct WildcardData **wcp)
|
|||
DEBUGASSERT(wc->ftpwc == NULL);
|
||||
|
||||
Curl_llist_destroy(&wc->filelist, NULL);
|
||||
free(wc->path);
|
||||
curlx_free(wc->path);
|
||||
wc->path = NULL;
|
||||
free(wc->pattern);
|
||||
curlx_free(wc->pattern);
|
||||
wc->pattern = NULL;
|
||||
wc->state = CURLWC_INIT;
|
||||
free(wc);
|
||||
curlx_free(wc);
|
||||
*wcp = NULL;
|
||||
}
|
||||
|
||||
struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct ftp_parselist_data));
|
||||
return curlx_calloc(1, sizeof(struct ftp_parselist_data));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -225,7 +221,7 @@ void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp)
|
|||
struct ftp_parselist_data *parser = *parserp;
|
||||
if(parser)
|
||||
Curl_fileinfo_cleanup(parser->file_data);
|
||||
free(parser);
|
||||
curlx_free(parser);
|
||||
*parserp = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
11
lib/getenv.c
11
lib/getenv.c
|
|
@ -25,9 +25,6 @@
|
|||
#include "curl_setup.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "curl_memory.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static char *GetEnv(const char *variable)
|
||||
{
|
||||
|
|
@ -45,9 +42,9 @@ static char *GetEnv(const char *variable)
|
|||
const DWORD max = 32768; /* max env var size from MSCRT source */
|
||||
|
||||
for(;;) {
|
||||
tmp = realloc(buf, rc);
|
||||
tmp = curlx_realloc(buf, rc);
|
||||
if(!tmp) {
|
||||
free(buf);
|
||||
curlx_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +55,7 @@ static char *GetEnv(const char *variable)
|
|||
Since getenv does not make that distinction we ignore it as well. */
|
||||
rc = GetEnvironmentVariableA(variable, buf, bufsize);
|
||||
if(!rc || rc == bufsize || rc > max) {
|
||||
free(buf);
|
||||
curlx_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +67,7 @@ static char *GetEnv(const char *variable)
|
|||
}
|
||||
#else
|
||||
char *env = getenv(variable);
|
||||
return (env && env[0]) ? strdup(env) : NULL;
|
||||
return (env && env[0]) ? curlx_strdup(env) : NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@
|
|||
#include "progress.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Initialize statistical and informational data.
|
||||
*
|
||||
|
|
@ -74,10 +70,10 @@ void Curl_initinfo(struct Curl_easy *data)
|
|||
info->httpauthpicked = 0;
|
||||
info->numconnects = 0;
|
||||
|
||||
free(info->contenttype);
|
||||
curlx_free(info->contenttype);
|
||||
info->contenttype = NULL;
|
||||
|
||||
free(info->wouldredirect);
|
||||
curlx_free(info->wouldredirect);
|
||||
info->wouldredirect = NULL;
|
||||
|
||||
memset(&info->primary, 0, sizeof(info->primary));
|
||||
|
|
@ -137,7 +133,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
|
|||
case CURLINFO_FTP_ENTRY_PATH:
|
||||
/* Return the entrypath string from the most recent connection.
|
||||
This pointer was copied from the connectdata structure by FTP.
|
||||
The actual string may be free()ed by subsequent libcurl calls so
|
||||
The actual string may be freed by subsequent libcurl calls so
|
||||
it must be copied to a safer area before the next libcurl call.
|
||||
Callers must never free it themselves. */
|
||||
*param_charp = data->state.most_recent_ftp_entrypath;
|
||||
|
|
|
|||
12
lib/gopher.c
12
lib/gopher.c
|
|
@ -40,10 +40,6 @@
|
|||
#include "escape.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last 2 #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
|
@ -153,7 +149,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
|
|||
if(query)
|
||||
gopherpath = curl_maprintf("%s?%s", path, query);
|
||||
else
|
||||
gopherpath = strdup(path);
|
||||
gopherpath = curlx_strdup(path);
|
||||
|
||||
if(!gopherpath)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -162,7 +158,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
|
|||
if(strlen(gopherpath) <= 2) {
|
||||
buf = "";
|
||||
buf_len = 0;
|
||||
free(gopherpath);
|
||||
curlx_free(gopherpath);
|
||||
}
|
||||
else {
|
||||
char *newp;
|
||||
|
|
@ -173,7 +169,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
|
|||
|
||||
/* ... and finally unescape */
|
||||
result = Curl_urldecode(newp, 0, &buf_alloc, &buf_len, REJECT_ZERO);
|
||||
free(gopherpath);
|
||||
curlx_free(gopherpath);
|
||||
if(result)
|
||||
return result;
|
||||
buf = buf_alloc;
|
||||
|
|
@ -224,7 +220,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
|
|||
}
|
||||
}
|
||||
|
||||
free(buf_alloc);
|
||||
curlx_free(buf_alloc);
|
||||
|
||||
if(!result)
|
||||
result = Curl_xfer_send(data, "\r\n", 2, FALSE, &nwritten);
|
||||
|
|
|
|||
10
lib/hash.c
10
lib/hash.c
|
|
@ -28,10 +28,6 @@
|
|||
|
||||
#include "hash.h"
|
||||
#include "llist.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
/* random patterns for API verification */
|
||||
#ifdef DEBUGBUILD
|
||||
|
|
@ -115,7 +111,7 @@ hash_elem_create(const void *key, size_t key_len, const void *p,
|
|||
struct Curl_hash_element *he;
|
||||
|
||||
/* allocate the struct plus memory after it to store the key */
|
||||
he = malloc(sizeof(struct Curl_hash_element) + key_len);
|
||||
he = curlx_malloc(sizeof(struct Curl_hash_element) + key_len);
|
||||
if(he) {
|
||||
he->next = NULL;
|
||||
/* copy the key */
|
||||
|
|
@ -145,7 +141,7 @@ static void hash_elem_destroy(struct Curl_hash *h,
|
|||
struct Curl_hash_element *he)
|
||||
{
|
||||
hash_elem_clear_ptr(h, he);
|
||||
free(he);
|
||||
curlx_free(he);
|
||||
}
|
||||
|
||||
static void hash_elem_unlink(struct Curl_hash *h,
|
||||
|
|
@ -177,7 +173,7 @@ void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p,
|
|||
DEBUGASSERT(h->slots);
|
||||
DEBUGASSERT(h->init == HASHINIT);
|
||||
if(!h->table) {
|
||||
h->table = calloc(h->slots, sizeof(struct Curl_hash_element *));
|
||||
h->table = curlx_calloc(h->slots, sizeof(struct Curl_hash_element *));
|
||||
if(!h->table)
|
||||
return NULL; /* OOM */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@
|
|||
#include "headers.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HEADERS_API)
|
||||
|
||||
/* Generate the curl_header struct for the user. This function MUST assign all
|
||||
|
|
@ -317,7 +313,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
|
|||
return CURLE_TOO_LARGE;
|
||||
}
|
||||
|
||||
hs = calloc(1, sizeof(*hs) + hlen);
|
||||
hs = curlx_calloc(1, sizeof(*hs) + hlen);
|
||||
if(!hs)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
memcpy(hs->buffer, header, hlen);
|
||||
|
|
@ -336,7 +332,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
|
|||
}
|
||||
else {
|
||||
failf(data, "Invalid response header");
|
||||
free(hs);
|
||||
curlx_free(hs);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -417,7 +413,7 @@ CURLcode Curl_headers_cleanup(struct Curl_easy *data)
|
|||
for(e = Curl_llist_head(&data->state.httphdrs); e; e = n) {
|
||||
struct Curl_header_store *hs = Curl_node_elem(e);
|
||||
n = Curl_node_next(e);
|
||||
free(hs);
|
||||
curlx_free(hs);
|
||||
}
|
||||
headers_reset(data);
|
||||
return CURLE_OK;
|
||||
|
|
|
|||
10
lib/hmac.c
10
lib/hmac.c
|
|
@ -33,12 +33,8 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include "curl_hmac.h"
|
||||
#include "curl_memory.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Generic HMAC algorithm.
|
||||
*
|
||||
|
|
@ -62,7 +58,7 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
|
|||
|
||||
/* Create HMAC context. */
|
||||
i = sizeof(*ctxt) + 2 * hashparams->ctxtsize + hashparams->resultlen;
|
||||
ctxt = malloc(i);
|
||||
ctxt = curlx_malloc(i);
|
||||
|
||||
if(!ctxt)
|
||||
return ctxt;
|
||||
|
|
@ -103,7 +99,7 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
|
|||
return ctxt;
|
||||
|
||||
fail:
|
||||
free(ctxt);
|
||||
curlx_free(ctxt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +126,7 @@ int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output)
|
|||
hashparams->hfinal(output, ctxt->hashctxt1);
|
||||
hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen);
|
||||
hashparams->hfinal(output, ctxt->hashctxt2);
|
||||
free(ctxt);
|
||||
curlx_free(ctxt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
22
lib/hostip.c
22
lib/hostip.c
|
|
@ -62,10 +62,6 @@
|
|||
#include "easy_lock.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(CURLRES_SYNCH) && \
|
||||
defined(HAVE_ALARM) && \
|
||||
defined(SIGALRM) && \
|
||||
|
|
@ -451,7 +447,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
struct Curl_addrinfo **nodes;
|
||||
infof(data, "Shuffling %i addresses", num_addrs);
|
||||
|
||||
nodes = malloc(num_addrs*sizeof(*nodes));
|
||||
nodes = curlx_malloc(num_addrs*sizeof(*nodes));
|
||||
if(nodes) {
|
||||
int i;
|
||||
unsigned int *rnd;
|
||||
|
|
@ -463,7 +459,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
nodes[i] = nodes[i-1]->ai_next;
|
||||
}
|
||||
|
||||
rnd = malloc(rnd_size);
|
||||
rnd = curlx_malloc(rnd_size);
|
||||
if(rnd) {
|
||||
/* Fisher-Yates shuffle */
|
||||
if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) {
|
||||
|
|
@ -482,11 +478,11 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
nodes[num_addrs-1]->ai_next = NULL;
|
||||
*addr = nodes[0];
|
||||
}
|
||||
free(rnd);
|
||||
curlx_free(rnd);
|
||||
}
|
||||
else
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
free(nodes);
|
||||
curlx_free(nodes);
|
||||
}
|
||||
else
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -519,7 +515,7 @@ Curl_dnscache_mk_entry(struct Curl_easy *data,
|
|||
hostlen = strlen(hostname);
|
||||
|
||||
/* Create a new cache entry */
|
||||
dns = calloc(1, sizeof(struct Curl_dns_entry) + hostlen);
|
||||
dns = curlx_calloc(1, sizeof(struct Curl_dns_entry) + hostlen);
|
||||
if(!dns)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -609,7 +605,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name)
|
|||
struct sockaddr_in6 sa6;
|
||||
unsigned char ipv6[16];
|
||||
unsigned short port16 = (unsigned short)(port & 0xffff);
|
||||
ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
|
||||
ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
|
||||
if(!ca)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -658,7 +654,7 @@ static struct Curl_addrinfo *get_localhost(int port, const char *name)
|
|||
return NULL;
|
||||
memcpy(&sa.sin_addr, &ipv4, sizeof(ipv4));
|
||||
|
||||
ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
|
||||
ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
|
||||
if(!ca)
|
||||
return NULL;
|
||||
ca->ai_flags = 0;
|
||||
|
|
@ -1178,10 +1174,10 @@ static void dnscache_entry_free(struct Curl_dns_entry *dns)
|
|||
#ifdef USE_HTTPSRR
|
||||
if(dns->hinfo) {
|
||||
Curl_httpsrr_cleanup(dns->hinfo);
|
||||
free(dns->hinfo);
|
||||
curlx_free(dns->hinfo);
|
||||
}
|
||||
#endif
|
||||
free(dns);
|
||||
curlx_free(dns);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@
|
|||
#include "curl_share.h"
|
||||
#include "url.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#ifdef CURLRES_SYNCH
|
||||
|
||||
|
|
@ -139,7 +135,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
*/
|
||||
int h_errnop;
|
||||
|
||||
buf = calloc(1, CURL_HOSTENT_SIZE);
|
||||
buf = curlx_calloc(1, CURL_HOSTENT_SIZE);
|
||||
if(!buf)
|
||||
return NULL; /* major failure */
|
||||
/*
|
||||
|
|
@ -253,8 +249,8 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
* Since we do not know how big buffer this particular lookup required,
|
||||
* we cannot realloc down the huge alloc without doing closer analysis of
|
||||
* the returned data. Thus, we always use CURL_HOSTENT_SIZE for every
|
||||
* name lookup. Fixing this would require an extra malloc() and then
|
||||
* calling Curl_addrinfo_copy() that subsequent realloc()s down the new
|
||||
* name lookup. Fixing this would require an extra allocation and then
|
||||
* calling Curl_addrinfo_copy() that subsequent reallocation down the new
|
||||
* memory area to the actually used amount.
|
||||
*/
|
||||
}
|
||||
|
|
@ -262,7 +258,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
#endif /* HAVE_...BYNAME_R_5 || HAVE_...BYNAME_R_6 || HAVE_...BYNAME_R_3 */
|
||||
{
|
||||
h = NULL; /* set return code to NULL */
|
||||
free(buf);
|
||||
curlx_free(buf);
|
||||
}
|
||||
#else /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) ||
|
||||
HAVE_GETHOSTBYNAME_R */
|
||||
|
|
@ -280,7 +276,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
ai = Curl_he2ai(h, port);
|
||||
|
||||
if(buf) /* used a *_r() function */
|
||||
free(buf);
|
||||
curlx_free(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -53,10 +53,6 @@
|
|||
#include "curlx/inet_pton.h"
|
||||
#include "connect.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef CURLRES_SYNCH
|
||||
|
||||
#ifdef DEBUG_ADDRINFO
|
||||
|
|
|
|||
24
lib/hsts.c
24
lib/hsts.c
|
|
@ -41,10 +41,6 @@
|
|||
#include "strdup.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define MAX_HSTS_LINE 4095
|
||||
#define MAX_HSTS_HOSTLEN 2048
|
||||
#define MAX_HSTS_DATELEN 256
|
||||
|
|
@ -72,7 +68,7 @@ static time_t hsts_debugtime(void *unused)
|
|||
|
||||
struct hsts *Curl_hsts_init(void)
|
||||
{
|
||||
struct hsts *h = calloc(1, sizeof(struct hsts));
|
||||
struct hsts *h = curlx_calloc(1, sizeof(struct hsts));
|
||||
if(h) {
|
||||
Curl_llist_init(&h->list, NULL);
|
||||
}
|
||||
|
|
@ -81,8 +77,8 @@ struct hsts *Curl_hsts_init(void)
|
|||
|
||||
static void hsts_free(struct stsentry *e)
|
||||
{
|
||||
free(CURL_UNCONST(e->host));
|
||||
free(e);
|
||||
curlx_free(CURL_UNCONST(e->host));
|
||||
curlx_free(e);
|
||||
}
|
||||
|
||||
void Curl_hsts_cleanup(struct hsts **hp)
|
||||
|
|
@ -96,8 +92,8 @@ void Curl_hsts_cleanup(struct hsts **hp)
|
|||
n = Curl_node_next(e);
|
||||
hsts_free(sts);
|
||||
}
|
||||
free(h->filename);
|
||||
free(h);
|
||||
curlx_free(h->filename);
|
||||
curlx_free(h);
|
||||
*hp = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -116,13 +112,13 @@ static CURLcode hsts_create(struct hsts *h,
|
|||
--hlen;
|
||||
if(hlen) {
|
||||
char *duphost;
|
||||
struct stsentry *sts = calloc(1, sizeof(struct stsentry));
|
||||
struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry));
|
||||
if(!sts)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
duphost = Curl_memdup0(hostname, hlen);
|
||||
if(!duphost) {
|
||||
free(sts);
|
||||
curlx_free(sts);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +381,7 @@ CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
|
|||
if(result && tempstore)
|
||||
unlink(tempstore);
|
||||
}
|
||||
free(tempstore);
|
||||
curlx_free(tempstore);
|
||||
skipsave:
|
||||
if(data->set.hsts_write) {
|
||||
/* if there is a write callback */
|
||||
|
|
@ -518,8 +514,8 @@ static CURLcode hsts_load(struct hsts *h, const char *file)
|
|||
|
||||
/* we need a private copy of the filename so that the hsts cache file
|
||||
name survives an easy handle reset */
|
||||
free(h->filename);
|
||||
h->filename = strdup(file);
|
||||
curlx_free(h->filename);
|
||||
h->filename = curlx_strdup(file);
|
||||
if(!h->filename)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
|||
106
lib/http.c
106
lib/http.c
|
|
@ -87,10 +87,6 @@
|
|||
#include "curl_ctype.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Forward declarations.
|
||||
*/
|
||||
|
|
@ -277,7 +273,7 @@ static bool http_header_is_empty(const char *header)
|
|||
|
||||
/*
|
||||
* Strip off leading and trailing whitespace from the value in the given HTTP
|
||||
* header line and return a strdup()ed copy in 'valp' - returns an empty
|
||||
* header line and return a strdup-ed copy in 'valp' - returns an empty
|
||||
* string if the header value consists entirely of whitespace.
|
||||
*
|
||||
* If the header is provided as "name;", ending with a semicolon, it returns a
|
||||
|
|
@ -305,7 +301,7 @@ static CURLcode copy_custom_value(const char *header, char **valp)
|
|||
|
||||
/*
|
||||
* Strip off leading and trailing whitespace from the value in the given HTTP
|
||||
* header line and return a strdup()ed copy in 'valp' - returns an empty
|
||||
* header line and return a strdup-ed copy in 'valp' - returns an empty
|
||||
* string if the header value consists entirely of whitespace.
|
||||
*
|
||||
* This function MUST be used after the header has already been confirmed to
|
||||
|
|
@ -377,18 +373,18 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
free(*userp);
|
||||
curlx_free(*userp);
|
||||
*userp = curl_maprintf("%sAuthorization: Basic %s\r\n",
|
||||
proxy ? "Proxy-" : "",
|
||||
authorization);
|
||||
free(authorization);
|
||||
curlx_free(authorization);
|
||||
if(!*userp) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
free(out);
|
||||
curlx_free(out);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +403,7 @@ static CURLcode http_output_bearer(struct Curl_easy *data)
|
|||
CURLcode result = CURLE_OK;
|
||||
|
||||
userp = &data->state.aptr.userpwd;
|
||||
free(*userp);
|
||||
curlx_free(*userp);
|
||||
*userp = curl_maprintf("Authorization: Bearer %s\r\n",
|
||||
data->set.str[STRING_BEARER]);
|
||||
|
||||
|
|
@ -615,8 +611,8 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
|
|||
/* In case this is GSS auth, the newurl field is already allocated so
|
||||
we must make sure to free it before allocating a new one. As figured
|
||||
out in bug #2284386 */
|
||||
free(data->req.newurl);
|
||||
data->req.newurl = strdup(data->state.url); /* clone URL */
|
||||
curlx_free(data->req.newurl);
|
||||
data->req.newurl = curlx_strdup(data->state.url); /* clone URL */
|
||||
if(!data->req.newurl)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -629,7 +625,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
|
|||
we did not try HEAD or GET */
|
||||
if((data->state.httpreq != HTTPREQ_GET) &&
|
||||
(data->state.httpreq != HTTPREQ_HEAD)) {
|
||||
data->req.newurl = strdup(data->state.url); /* clone URL */
|
||||
data->req.newurl = curlx_strdup(data->state.url); /* clone URL */
|
||||
if(!data->req.newurl)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
data->state.authhost.done = TRUE;
|
||||
|
|
@ -916,8 +912,8 @@ static CURLcode auth_spnego(struct Curl_easy *data,
|
|||
curlnegotiate *negstate = proxy ? &conn->proxy_negotiate_state :
|
||||
&conn->http_negotiate_state;
|
||||
if(!result) {
|
||||
free(data->req.newurl);
|
||||
data->req.newurl = strdup(data->state.url);
|
||||
curlx_free(data->req.newurl);
|
||||
data->req.newurl = curlx_strdup(data->state.url);
|
||||
if(!data->req.newurl)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
data->state.authproblem = FALSE;
|
||||
|
|
@ -1291,7 +1287,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
|
|||
|
||||
/* the URL could not be parsed for some reason, but since this is FAKE
|
||||
mode, just duplicate the field as-is */
|
||||
follow_url = strdup(newurl);
|
||||
follow_url = curlx_strdup(newurl);
|
||||
if(!follow_url)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -1316,13 +1312,13 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
|
|||
uc = curl_url_get(data->state.uh, CURLUPART_PORT, &portnum,
|
||||
CURLU_DEFAULT_PORT);
|
||||
if(uc) {
|
||||
free(follow_url);
|
||||
curlx_free(follow_url);
|
||||
return Curl_uc_to_curlcode(uc);
|
||||
}
|
||||
p = portnum;
|
||||
curlx_str_number(&p, &value, 0xffff);
|
||||
port = (int)value;
|
||||
free(portnum);
|
||||
curlx_free(portnum);
|
||||
}
|
||||
if(port != data->info.conn_remote_port) {
|
||||
infof(data, "Clear auth, redirects to port from %u to %u",
|
||||
|
|
@ -1334,7 +1330,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
|
|||
const struct Curl_handler *p;
|
||||
uc = curl_url_get(data->state.uh, CURLUPART_SCHEME, &scheme, 0);
|
||||
if(uc) {
|
||||
free(follow_url);
|
||||
curlx_free(follow_url);
|
||||
return Curl_uc_to_curlcode(uc);
|
||||
}
|
||||
|
||||
|
|
@ -1344,7 +1340,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
|
|||
data->info.conn_scheme, scheme);
|
||||
clear = TRUE;
|
||||
}
|
||||
free(scheme);
|
||||
curlx_free(scheme);
|
||||
}
|
||||
if(clear) {
|
||||
Curl_safefree(data->state.aptr.user);
|
||||
|
|
@ -1917,7 +1913,7 @@ static CURLcode http_useragent(struct Curl_easy *data)
|
|||
with the user-agent string specified, we erase the previously made string
|
||||
here. */
|
||||
if(Curl_checkheaders(data, STRCONST("User-Agent"))) {
|
||||
free(data->state.aptr.uagent);
|
||||
curlx_free(data->state.aptr.uagent);
|
||||
data->state.aptr.uagent = NULL;
|
||||
}
|
||||
return CURLE_OK;
|
||||
|
|
@ -1932,9 +1928,9 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
|
|||
|
||||
if(!data->state.this_is_a_follow) {
|
||||
/* Free to avoid leaking memory on multiple requests */
|
||||
free(data->state.first_host);
|
||||
curlx_free(data->state.first_host);
|
||||
|
||||
data->state.first_host = strdup(conn->host.name);
|
||||
data->state.first_host = curlx_strdup(conn->host.name);
|
||||
if(!data->state.first_host)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -1958,7 +1954,7 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
|
|||
return result;
|
||||
if(!*cookiehost)
|
||||
/* ignore empty data */
|
||||
free(cookiehost);
|
||||
curlx_free(cookiehost);
|
||||
else {
|
||||
/* If the host begins with '[', we start searching for the port after
|
||||
the bracket has been closed */
|
||||
|
|
@ -1977,7 +1973,7 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
|
|||
if(colon)
|
||||
*colon = 0; /* The host must not include an embedded port number */
|
||||
}
|
||||
free(aptr->cookiehost);
|
||||
curlx_free(aptr->cookiehost);
|
||||
aptr->cookiehost = cookiehost;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2086,7 +2082,7 @@ static CURLcode http_target(struct Curl_easy *data,
|
|||
/* target or URL */
|
||||
result = curlx_dyn_add(r, data->set.str[STRING_TARGET] ?
|
||||
data->set.str[STRING_TARGET] : url);
|
||||
free(url);
|
||||
curlx_free(url);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2142,7 +2138,7 @@ static CURLcode set_post_reader(struct Curl_easy *data, Curl_HttpReq httpreq)
|
|||
/* Convert the form structure into a mime structure, then keep
|
||||
the conversion */
|
||||
if(!data->state.formp) {
|
||||
data->state.formp = calloc(1, sizeof(curl_mimepart));
|
||||
data->state.formp = curlx_calloc(1, sizeof(curl_mimepart));
|
||||
if(!data->state.formp)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
Curl_mime_cleanpart(data->state.formp);
|
||||
|
|
@ -2547,7 +2543,7 @@ static CURLcode http_range(struct Curl_easy *data,
|
|||
if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) &&
|
||||
!Curl_checkheaders(data, STRCONST("Range"))) {
|
||||
/* if a line like this was already allocated, free the previous one */
|
||||
free(data->state.aptr.rangeline);
|
||||
curlx_free(data->state.aptr.rangeline);
|
||||
data->state.aptr.rangeline = curl_maprintf("Range: bytes=%s\r\n",
|
||||
data->state.range);
|
||||
if(!data->state.aptr.rangeline)
|
||||
|
|
@ -2557,7 +2553,7 @@ static CURLcode http_range(struct Curl_easy *data,
|
|||
!Curl_checkheaders(data, STRCONST("Content-Range"))) {
|
||||
curl_off_t req_clen = Curl_creader_total_length(data);
|
||||
/* if a line like this was already allocated, free the previous one */
|
||||
free(data->state.aptr.rangeline);
|
||||
curlx_free(data->state.aptr.rangeline);
|
||||
|
||||
if(data->set.set_resume_from < 0) {
|
||||
/* Upload resume was asked for, but we do not know the size of the
|
||||
|
|
@ -2723,7 +2719,7 @@ static CURLcode http_add_connection_hd(struct Curl_easy *data,
|
|||
return result;
|
||||
result = curlx_dyn_addf(req, "%s%s", sep, value);
|
||||
sep = ", ";
|
||||
free(value);
|
||||
curlx_free(value);
|
||||
break; /* leave, having added 1st one */
|
||||
}
|
||||
}
|
||||
|
|
@ -3000,7 +2996,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
|
|||
}
|
||||
result = Curl_http_output_auth(data, data->conn, method, httpreq,
|
||||
(pq ? pq : data->state.up.path), FALSE);
|
||||
free(pq);
|
||||
curlx_free(pq);
|
||||
}
|
||||
if(result)
|
||||
goto out;
|
||||
|
|
@ -3245,9 +3241,9 @@ static CURLcode http_header_c(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
if(!*contenttype)
|
||||
/* ignore empty data */
|
||||
free(contenttype);
|
||||
curlx_free(contenttype);
|
||||
else {
|
||||
free(data->info.contenttype);
|
||||
curlx_free(data->info.contenttype);
|
||||
data->info.contenttype = contenttype;
|
||||
}
|
||||
return CURLE_OK;
|
||||
|
|
@ -3333,14 +3329,14 @@ static CURLcode http_header_l(struct Curl_easy *data,
|
|||
if(!*location ||
|
||||
(data->req.location && !strcmp(data->req.location, location))) {
|
||||
/* ignore empty header, or exact repeat of a previous one */
|
||||
free(location);
|
||||
curlx_free(location);
|
||||
return CURLE_OK;
|
||||
}
|
||||
else {
|
||||
/* has value and is not an exact repeat */
|
||||
if(data->req.location) {
|
||||
failf(data, "Multiple Location headers");
|
||||
free(location);
|
||||
curlx_free(location);
|
||||
return CURLE_WEIRD_SERVER_REPLY;
|
||||
}
|
||||
data->req.location = location;
|
||||
|
|
@ -3349,7 +3345,7 @@ static CURLcode http_header_l(struct Curl_easy *data,
|
|||
data->set.http_follow_mode) {
|
||||
CURLcode result;
|
||||
DEBUGASSERT(!data->req.newurl);
|
||||
data->req.newurl = strdup(data->req.location); /* clone */
|
||||
data->req.newurl = curlx_strdup(data->req.location); /* clone */
|
||||
if(!data->req.newurl)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -3407,7 +3403,7 @@ static CURLcode http_header_p(struct Curl_easy *data,
|
|||
CURLcode result = auth ? CURLE_OK : CURLE_OUT_OF_MEMORY;
|
||||
if(!result) {
|
||||
result = Curl_http_input_auth(data, TRUE, auth);
|
||||
free(auth);
|
||||
curlx_free(auth);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -3426,7 +3422,7 @@ static CURLcode http_header_p(struct Curl_easy *data,
|
|||
negdata->havenoauthpersist = TRUE;
|
||||
infof(data, "Negotiate: noauthpersist -> %d, header part: %s",
|
||||
negdata->noauthpersist, persistentauth);
|
||||
free(persistentauth);
|
||||
curlx_free(persistentauth);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -3587,7 +3583,7 @@ static CURLcode http_header_w(struct Curl_easy *data,
|
|||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
result = Curl_http_input_auth(data, FALSE, auth);
|
||||
free(auth);
|
||||
curlx_free(auth);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -4065,7 +4061,7 @@ static CURLcode http_on_response(struct Curl_easy *data,
|
|||
data->state.disableexpect = TRUE;
|
||||
Curl_req_abort_sending(data);
|
||||
DEBUGASSERT(!data->req.newurl);
|
||||
data->req.newurl = strdup(data->state.url);
|
||||
data->req.newurl = curlx_strdup(data->state.url);
|
||||
if(!data->req.newurl) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -4533,7 +4529,7 @@ CURLcode Curl_http_req_make(struct httpreq **preq,
|
|||
|
||||
DEBUGASSERT(method && m_len);
|
||||
|
||||
req = calloc(1, sizeof(*req) + m_len);
|
||||
req = curlx_calloc(1, sizeof(*req) + m_len);
|
||||
if(!req)
|
||||
goto out;
|
||||
#if defined(__GNUC__) && __GNUC__ >= 13
|
||||
|
|
@ -4606,8 +4602,8 @@ static CURLcode req_assign_url_authority(struct httpreq *req, CURLU *url)
|
|||
}
|
||||
req->authority = curlx_dyn_ptr(&buf);
|
||||
out:
|
||||
free(host);
|
||||
free(port);
|
||||
curlx_free(host);
|
||||
curlx_free(port);
|
||||
if(result)
|
||||
curlx_dyn_free(&buf);
|
||||
return result;
|
||||
|
|
@ -4645,8 +4641,8 @@ static CURLcode req_assign_url_path(struct httpreq *req, CURLU *url)
|
|||
result = CURLE_OK;
|
||||
|
||||
out:
|
||||
free(path);
|
||||
free(query);
|
||||
curlx_free(path);
|
||||
curlx_free(query);
|
||||
if(result)
|
||||
curlx_dyn_free(&buf);
|
||||
return result;
|
||||
|
|
@ -4662,7 +4658,7 @@ CURLcode Curl_http_req_make2(struct httpreq **preq,
|
|||
|
||||
DEBUGASSERT(method && m_len);
|
||||
|
||||
req = calloc(1, sizeof(*req) + m_len);
|
||||
req = curlx_calloc(1, sizeof(*req) + m_len);
|
||||
if(!req)
|
||||
goto out;
|
||||
memcpy(req->method, method, m_len);
|
||||
|
|
@ -4671,7 +4667,7 @@ CURLcode Curl_http_req_make2(struct httpreq **preq,
|
|||
if(uc && uc != CURLUE_NO_SCHEME)
|
||||
goto out;
|
||||
if(!req->scheme && scheme_default) {
|
||||
req->scheme = strdup(scheme_default);
|
||||
req->scheme = curlx_strdup(scheme_default);
|
||||
if(!req->scheme)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -4697,12 +4693,12 @@ out:
|
|||
void Curl_http_req_free(struct httpreq *req)
|
||||
{
|
||||
if(req) {
|
||||
free(req->scheme);
|
||||
free(req->authority);
|
||||
free(req->path);
|
||||
curlx_free(req->scheme);
|
||||
curlx_free(req->authority);
|
||||
curlx_free(req->path);
|
||||
Curl_dynhds_free(&req->headers);
|
||||
Curl_dynhds_free(&req->trailers);
|
||||
free(req);
|
||||
curlx_free(req);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4840,13 +4836,13 @@ CURLcode Curl_http_resp_make(struct http_resp **presp,
|
|||
struct http_resp *resp;
|
||||
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||
|
||||
resp = calloc(1, sizeof(*resp));
|
||||
resp = curlx_calloc(1, sizeof(*resp));
|
||||
if(!resp)
|
||||
goto out;
|
||||
|
||||
resp->status = status;
|
||||
if(description) {
|
||||
resp->description = strdup(description);
|
||||
resp->description = curlx_strdup(description);
|
||||
if(!resp->description)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -4864,12 +4860,12 @@ out:
|
|||
void Curl_http_resp_free(struct http_resp *resp)
|
||||
{
|
||||
if(resp) {
|
||||
free(resp->description);
|
||||
curlx_free(resp->description);
|
||||
Curl_dynhds_free(&resp->headers);
|
||||
Curl_dynhds_free(&resp->trailers);
|
||||
if(resp->prev)
|
||||
Curl_http_resp_free(resp->prev);
|
||||
free(resp);
|
||||
curlx_free(resp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@
|
|||
#include "http1.h"
|
||||
#include "urlapi-int.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#define H1_MAX_URL_LEN (8*1024)
|
||||
|
||||
|
|
|
|||
30
lib/http2.c
30
lib/http2.c
|
|
@ -48,10 +48,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "headers.h"
|
||||
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if (NGHTTP2_VERSION_NUM < 0x010c00)
|
||||
#error too old nghttp2 version, upgrade!
|
||||
#endif
|
||||
|
|
@ -168,7 +164,7 @@ static void cf_h2_ctx_free(struct cf_h2_ctx *ctx)
|
|||
Curl_uint32_hash_destroy(&ctx->streams);
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
|
||||
static void cf_h2_ctx_close(struct cf_h2_ctx *ctx)
|
||||
|
|
@ -276,7 +272,7 @@ static struct h2_stream_ctx *h2_stream_ctx_create(struct cf_h2_ctx *ctx)
|
|||
struct h2_stream_ctx *stream;
|
||||
|
||||
(void)ctx;
|
||||
stream = calloc(1, sizeof(*stream));
|
||||
stream = curlx_calloc(1, sizeof(*stream));
|
||||
if(!stream)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -299,7 +295,7 @@ static void free_push_headers(struct h2_stream_ctx *stream)
|
|||
{
|
||||
size_t i;
|
||||
for(i = 0; i < stream->push_headers_used; i++)
|
||||
free(stream->push_headers[i]);
|
||||
curlx_free(stream->push_headers[i]);
|
||||
Curl_safefree(stream->push_headers);
|
||||
stream->push_headers_used = 0;
|
||||
}
|
||||
|
|
@ -310,7 +306,7 @@ static void h2_stream_ctx_free(struct h2_stream_ctx *stream)
|
|||
Curl_h1_req_parse_free(&stream->h1);
|
||||
Curl_dynhds_free(&stream->resp_trailers);
|
||||
free_push_headers(stream);
|
||||
free(stream);
|
||||
curlx_free(stream);
|
||||
}
|
||||
|
||||
static void h2_stream_hash_free(unsigned int id, void *stream)
|
||||
|
|
@ -952,7 +948,7 @@ fail:
|
|||
return rc;
|
||||
|
||||
if(data->state.url_alloc)
|
||||
free(data->state.url);
|
||||
curlx_free(data->state.url);
|
||||
data->state.url_alloc = TRUE;
|
||||
data->state.url = url;
|
||||
return 0;
|
||||
|
|
@ -1642,15 +1638,15 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
stream_id, NGHTTP2_PROTOCOL_ERROR);
|
||||
rc = NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
}
|
||||
free(check);
|
||||
curlx_free(check);
|
||||
if(rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if(!stream->push_headers) {
|
||||
stream->push_headers_alloc = 10;
|
||||
stream->push_headers = malloc(stream->push_headers_alloc *
|
||||
sizeof(char *));
|
||||
stream->push_headers = curlx_malloc(stream->push_headers_alloc *
|
||||
sizeof(char *));
|
||||
if(!stream->push_headers)
|
||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
stream->push_headers_used = 0;
|
||||
|
|
@ -1665,8 +1661,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
}
|
||||
stream->push_headers_alloc *= 2;
|
||||
headp = realloc(stream->push_headers,
|
||||
stream->push_headers_alloc * sizeof(char *));
|
||||
headp = curlx_realloc(stream->push_headers,
|
||||
stream->push_headers_alloc * sizeof(char *));
|
||||
if(!headp) {
|
||||
free_push_headers(stream);
|
||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
|
|
@ -1859,7 +1855,7 @@ CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
|
|||
"Upgrade: %s\r\n"
|
||||
"HTTP2-Settings: %s\r\n",
|
||||
NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64);
|
||||
free(base64);
|
||||
curlx_free(base64);
|
||||
|
||||
k->upgr101 = UPGR101_H2;
|
||||
data->conn->bits.upgrade_in_progress = TRUE;
|
||||
|
|
@ -2881,7 +2877,7 @@ static CURLcode http2_cfilter_add(struct Curl_cfilter **pcf,
|
|||
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||
|
||||
DEBUGASSERT(data->conn);
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx)
|
||||
goto out;
|
||||
cf_h2_ctx_init(ctx, via_h1_upgrade);
|
||||
|
|
@ -2909,7 +2905,7 @@ static CURLcode http2_cfilter_insert_after(struct Curl_cfilter *cf,
|
|||
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||
|
||||
(void)data;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx)
|
||||
goto out;
|
||||
cf_h2_ctx_init(ctx, via_h1_upgrade);
|
||||
|
|
|
|||
|
|
@ -39,10 +39,6 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#include "slist.h"
|
||||
|
||||
#define HMAC_SHA256(k, kl, d, dl, o) \
|
||||
|
|
@ -210,12 +206,12 @@ static CURLcode merge_duplicate_headers(struct curl_slist *head)
|
|||
if(result)
|
||||
return result;
|
||||
|
||||
free(curr->data);
|
||||
curlx_free(curr->data);
|
||||
curr->data = curlx_dyn_ptr(&buf);
|
||||
|
||||
curr->next = next->next;
|
||||
free(next->data);
|
||||
free(next);
|
||||
curlx_free(next->data);
|
||||
curlx_free(next);
|
||||
}
|
||||
else {
|
||||
curr = curr->next;
|
||||
|
|
@ -269,7 +265,7 @@ static CURLcode make_headers(struct Curl_easy *data,
|
|||
if(fullhost)
|
||||
head = Curl_slist_append_nodup(NULL, fullhost);
|
||||
if(!head) {
|
||||
free(fullhost);
|
||||
curlx_free(fullhost);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
|
@ -307,13 +303,13 @@ static CURLcode make_headers(struct Curl_easy *data,
|
|||
;
|
||||
if(!*ptr && ptr != sep + 1) /* a value of whitespace only */
|
||||
continue;
|
||||
dupdata = strdup(l->data);
|
||||
dupdata = curlx_strdup(l->data);
|
||||
if(!dupdata)
|
||||
goto fail;
|
||||
dupdata[sep - l->data] = ':';
|
||||
tmp_head = Curl_slist_append_nodup(head, dupdata);
|
||||
if(!tmp_head) {
|
||||
free(dupdata);
|
||||
curlx_free(dupdata);
|
||||
goto fail;
|
||||
}
|
||||
head = tmp_head;
|
||||
|
|
@ -964,7 +960,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
|
|||
Curl_strntoupper(&auth_headers[sizeof("Authorization: ") - 1],
|
||||
curlx_str(&provider0), curlx_strlen(&provider0));
|
||||
|
||||
free(data->state.aptr.userpwd);
|
||||
curlx_free(data->state.aptr.userpwd);
|
||||
data->state.aptr.userpwd = auth_headers;
|
||||
data->state.authhost.done = TRUE;
|
||||
result = CURLE_OK;
|
||||
|
|
@ -974,12 +970,12 @@ fail:
|
|||
curlx_dyn_free(&canonical_path);
|
||||
curlx_dyn_free(&canonical_headers);
|
||||
curlx_dyn_free(&signed_headers);
|
||||
free(canonical_request);
|
||||
free(request_type);
|
||||
free(credential_scope);
|
||||
free(str_to_sign);
|
||||
free(secret);
|
||||
free(date_header);
|
||||
curlx_free(canonical_request);
|
||||
curlx_free(request_type);
|
||||
curlx_free(credential_scope);
|
||||
curlx_free(str_to_sign);
|
||||
curlx_free(secret);
|
||||
curlx_free(date_header);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@
|
|||
#include "curlx/strparse.h"
|
||||
#include "curlx/warnless.h"
|
||||
|
||||
/* The last #include files should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Chunk format (simplified):
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@
|
|||
#include "http_digest.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test example headers:
|
||||
|
||||
WWW-Authenticate: Digest realm="testrealm", nonce="1053604598"
|
||||
|
|
@ -152,20 +148,20 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
|
|||
}
|
||||
}
|
||||
if(!tmp)
|
||||
path = (unsigned char *)strdup((const char *) uripath);
|
||||
path = (unsigned char *)curlx_strdup((const char *) uripath);
|
||||
|
||||
if(!path)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = Curl_auth_create_digest_http_message(data, userp, passwdp, request,
|
||||
path, digest, &response, &len);
|
||||
free(path);
|
||||
curlx_free(path);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
*allocuserpwd = curl_maprintf("%sAuthorization: Digest %s\r\n",
|
||||
proxy ? "Proxy-" : "", response);
|
||||
free(response);
|
||||
curlx_free(response);
|
||||
if(!*allocuserpwd)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@
|
|||
#include "vtls/vtls.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
static void http_auth_nego_reset(struct connectdata *conn,
|
||||
struct negotiatedata *neg_ctx,
|
||||
|
|
@ -223,16 +219,16 @@ CURLcode Curl_output_negotiate(struct Curl_easy *data,
|
|||
|
||||
if(proxy) {
|
||||
#ifndef CURL_DISABLE_PROXY
|
||||
free(data->state.aptr.proxyuserpwd);
|
||||
curlx_free(data->state.aptr.proxyuserpwd);
|
||||
data->state.aptr.proxyuserpwd = userp;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
free(data->state.aptr.userpwd);
|
||||
curlx_free(data->state.aptr.userpwd);
|
||||
data->state.aptr.userpwd = userp;
|
||||
}
|
||||
|
||||
free(base64);
|
||||
curlx_free(base64);
|
||||
|
||||
if(!userp) {
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@
|
|||
#include "curl_sspi.h"
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
CURLcode Curl_input_ntlm(struct Curl_easy *data,
|
||||
bool proxy, /* if proxy or not */
|
||||
const char *header) /* rest of the www-authenticate:
|
||||
|
|
@ -208,11 +204,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
|
|||
result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
|
||||
Curl_bufref_len(&ntlmmsg), &base64, &len);
|
||||
if(!result) {
|
||||
free(*allocuserpwd);
|
||||
curlx_free(*allocuserpwd);
|
||||
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
|
||||
proxy ? "Proxy-" : "",
|
||||
base64);
|
||||
free(base64);
|
||||
curlx_free(base64);
|
||||
if(!*allocuserpwd)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -227,11 +223,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
|
|||
result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
|
||||
Curl_bufref_len(&ntlmmsg), &base64, &len);
|
||||
if(!result) {
|
||||
free(*allocuserpwd);
|
||||
curlx_free(*allocuserpwd);
|
||||
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
|
||||
proxy ? "Proxy-" : "",
|
||||
base64);
|
||||
free(base64);
|
||||
curlx_free(base64);
|
||||
if(!*allocuserpwd)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@
|
|||
#include "vauth/vauth.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static CURLcode dynhds_add_custom(struct Curl_easy *data,
|
||||
bool is_connect, int httpversion,
|
||||
struct dynhds *hds)
|
||||
|
|
@ -270,7 +266,7 @@ out:
|
|||
Curl_http_req_free(req);
|
||||
req = NULL;
|
||||
}
|
||||
free(authority);
|
||||
curlx_free(authority);
|
||||
*preq = req;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -386,7 +382,7 @@ static void http_proxy_cf_destroy(struct Curl_cfilter *cf,
|
|||
|
||||
(void)data;
|
||||
CURL_TRC_CF(data, cf, "destroy");
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
}
|
||||
|
||||
static void http_proxy_cf_close(struct Curl_cfilter *cf,
|
||||
|
|
@ -425,7 +421,7 @@ CURLcode Curl_cf_http_proxy_insert_after(struct Curl_cfilter *cf_at,
|
|||
CURLcode result;
|
||||
|
||||
(void)data;
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
ctx = curlx_calloc(1, sizeof(*ctx));
|
||||
if(!ctx) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -437,7 +433,7 @@ CURLcode Curl_cf_http_proxy_insert_after(struct Curl_cfilter *cf_at,
|
|||
Curl_conn_cf_insert_after(cf_at, cf);
|
||||
|
||||
out:
|
||||
free(ctx);
|
||||
curlx_free(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@
|
|||
#include "sendf.h"
|
||||
#include "strdup.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static CURLcode httpsrr_decode_alpn(const uint8_t *cp, size_t len,
|
||||
unsigned char *alpns)
|
||||
{
|
||||
|
|
@ -97,7 +93,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data,
|
|||
case HTTPS_RR_CODE_IPV4: /* addr4 list */
|
||||
if(!vlen || (vlen & 3)) /* the size must be 4-byte aligned */
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
free(hi->ipv4hints);
|
||||
curlx_free(hi->ipv4hints);
|
||||
hi->ipv4hints = Curl_memdup(val, vlen);
|
||||
if(!hi->ipv4hints)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -107,7 +103,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data,
|
|||
case HTTPS_RR_CODE_ECH:
|
||||
if(!vlen)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
free(hi->echconfiglist);
|
||||
curlx_free(hi->echconfiglist);
|
||||
hi->echconfiglist = Curl_memdup(val, vlen);
|
||||
if(!hi->echconfiglist)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -117,7 +113,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data,
|
|||
case HTTPS_RR_CODE_IPV6: /* addr6 list */
|
||||
if(!vlen || (vlen & 15)) /* the size must be 16-byte aligned */
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
free(hi->ipv6hints);
|
||||
curlx_free(hi->ipv6hints);
|
||||
hi->ipv6hints = Curl_memdup(val, vlen);
|
||||
if(!hi->ipv6hints)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -189,8 +185,8 @@ CURLcode Curl_httpsrr_from_ares(struct Curl_easy *data,
|
|||
is in ServiceMode */
|
||||
target = ares_dns_rr_get_str(rr, ARES_RR_HTTPS_TARGET);
|
||||
if(target && target[0]) {
|
||||
free(hinfo->target);
|
||||
hinfo->target = strdup(target);
|
||||
curlx_free(hinfo->target);
|
||||
hinfo->target = curlx_strdup(target);
|
||||
if(!hinfo->target) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
|
|||
18
lib/idn.c
18
lib/idn.c
|
|
@ -45,10 +45,6 @@
|
|||
#endif
|
||||
#endif /* USE_LIBIDN2 */
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* for macOS and iOS targets */
|
||||
#ifdef USE_APPLE_IDN
|
||||
#include <unicode/uidna.h>
|
||||
|
|
@ -108,7 +104,7 @@ static CURLcode mac_idn_to_ascii(const char *in, char **out)
|
|||
buffer, sizeof(buffer) - 1, &info, &err);
|
||||
uidna_close(idna);
|
||||
if(!U_FAILURE(err) && !info.errors) {
|
||||
*out = strdup(buffer);
|
||||
*out = curlx_strdup(buffer);
|
||||
if(*out)
|
||||
return CURLE_OK;
|
||||
else
|
||||
|
|
@ -136,7 +132,7 @@ static CURLcode mac_ascii_to_idn(const char *in, char **out)
|
|||
sizeof(buffer) - 1, &info, &err);
|
||||
uidna_close(idna);
|
||||
if(!U_FAILURE(err)) {
|
||||
*out = strdup(buffer);
|
||||
*out = curlx_strdup(buffer);
|
||||
if(*out)
|
||||
return CURLE_OK;
|
||||
else
|
||||
|
|
@ -179,7 +175,7 @@ static CURLcode win32_idn_to_ascii(const char *in, char **out)
|
|||
if(chars) {
|
||||
char *mstr = curlx_convert_wchar_to_UTF8(punycode);
|
||||
if(mstr) {
|
||||
*out = strdup(mstr);
|
||||
*out = curlx_strdup(mstr);
|
||||
curlx_unicodefree(mstr);
|
||||
if(!*out)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -209,7 +205,7 @@ static CURLcode win32_ascii_to_idn(const char *in, char **output)
|
|||
/* 'chars' is "the number of characters retrieved" */
|
||||
char *mstr = curlx_convert_wchar_to_UTF8(idn);
|
||||
if(mstr) {
|
||||
out = strdup(mstr);
|
||||
out = curlx_strdup(mstr);
|
||||
curlx_unicodefree(mstr);
|
||||
if(!out)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -314,7 +310,7 @@ CURLcode Curl_idn_decode(const char *input, char **output)
|
|||
CURLcode result = idn_decode(input, &d);
|
||||
#ifdef USE_LIBIDN2
|
||||
if(!result) {
|
||||
char *c = strdup(d);
|
||||
char *c = curlx_strdup(d);
|
||||
idn2_free(d);
|
||||
if(c)
|
||||
d = c;
|
||||
|
|
@ -325,7 +321,7 @@ CURLcode Curl_idn_decode(const char *input, char **output)
|
|||
if(!result) {
|
||||
if(!d[0]) { /* ended up zero length, not acceptable */
|
||||
result = CURLE_URL_MALFORMAT;
|
||||
free(d);
|
||||
curlx_free(d);
|
||||
}
|
||||
else
|
||||
*output = d;
|
||||
|
|
@ -339,7 +335,7 @@ CURLcode Curl_idn_encode(const char *puny, char **output)
|
|||
CURLcode result = idn_encode(puny, &d);
|
||||
#ifdef USE_LIBIDN2
|
||||
if(!result) {
|
||||
char *c = strdup(d);
|
||||
char *c = curlx_strdup(d);
|
||||
idn2_free(d);
|
||||
if(c)
|
||||
d = c;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,6 @@
|
|||
#include "curlx/inet_ntop.h"
|
||||
#include "if2ip.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#ifdef USE_IPV6
|
||||
|
|
|
|||
42
lib/imap.c
42
lib/imap.c
|
|
@ -78,10 +78,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "curl_ctype.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
/* meta key for storing protocol meta at easy handle */
|
||||
#define CURL_META_IMAP_EASY "meta:proto:imap:easy"
|
||||
|
|
@ -617,8 +613,8 @@ static CURLcode imap_perform_login(struct Curl_easy *data,
|
|||
result = imap_sendf(data, imapc, "LOGIN %s %s", user ? user : "",
|
||||
passwd ? passwd : "");
|
||||
|
||||
free(user);
|
||||
free(passwd);
|
||||
curlx_free(user);
|
||||
curlx_free(passwd);
|
||||
|
||||
if(!result)
|
||||
imap_state(data, imapc, IMAP_LOGIN);
|
||||
|
|
@ -751,14 +747,14 @@ static CURLcode imap_perform_list(struct Curl_easy *data,
|
|||
else {
|
||||
/* Make sure the mailbox is in the correct atom format if necessary */
|
||||
char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, TRUE)
|
||||
: strdup("");
|
||||
: curlx_strdup("");
|
||||
if(!mailbox)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* Send the LIST command */
|
||||
result = imap_sendf(data, imapc, "LIST \"%s\" *", mailbox);
|
||||
|
||||
free(mailbox);
|
||||
curlx_free(mailbox);
|
||||
}
|
||||
|
||||
if(!result)
|
||||
|
|
@ -797,7 +793,7 @@ static CURLcode imap_perform_select(struct Curl_easy *data,
|
|||
/* Send the SELECT command */
|
||||
result = imap_sendf(data, imapc, "SELECT %s", mailbox);
|
||||
|
||||
free(mailbox);
|
||||
curlx_free(mailbox);
|
||||
|
||||
if(!result)
|
||||
imap_state(data, imapc, IMAP_SELECT);
|
||||
|
|
@ -947,7 +943,7 @@ static CURLcode imap_perform_append(struct Curl_easy *data,
|
|||
|
||||
cleanup:
|
||||
curlx_dyn_free(&flags);
|
||||
free(mailbox);
|
||||
curlx_free(mailbox);
|
||||
|
||||
if(!result)
|
||||
imap_state(data, imapc, IMAP_APPEND);
|
||||
|
|
@ -1338,7 +1334,7 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data,
|
|||
else {
|
||||
/* Note the currently opened mailbox on this connection */
|
||||
DEBUGASSERT(!imapc->mailbox);
|
||||
imapc->mailbox = strdup(imap->mailbox);
|
||||
imapc->mailbox = curlx_strdup(imap->mailbox);
|
||||
if(!imapc->mailbox)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -1967,7 +1963,7 @@ static void imap_easy_dtor(void *key, size_t klen, void *entry)
|
|||
(void)key;
|
||||
(void)klen;
|
||||
imap_easy_reset(imap);
|
||||
free(imap);
|
||||
curlx_free(imap);
|
||||
}
|
||||
|
||||
static void imap_conn_dtor(void *key, size_t klen, void *entry)
|
||||
|
|
@ -1978,7 +1974,7 @@ static void imap_conn_dtor(void *key, size_t klen, void *entry)
|
|||
Curl_pp_disconnect(&imapc->pp);
|
||||
curlx_dyn_free(&imapc->dyn);
|
||||
Curl_safefree(imapc->mailbox);
|
||||
free(imapc);
|
||||
curlx_free(imapc);
|
||||
}
|
||||
|
||||
static CURLcode imap_setup_connection(struct Curl_easy *data,
|
||||
|
|
@ -1988,7 +1984,7 @@ static CURLcode imap_setup_connection(struct Curl_easy *data,
|
|||
struct pingpong *pp;
|
||||
struct IMAP *imap;
|
||||
|
||||
imapc = calloc(1, sizeof(*imapc));
|
||||
imapc = curlx_calloc(1, sizeof(*imapc));
|
||||
if(!imapc)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -2005,7 +2001,7 @@ static CURLcode imap_setup_connection(struct Curl_easy *data,
|
|||
if(Curl_conn_meta_set(conn, CURL_META_IMAP_CONN, imapc, imap_conn_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
imap = calloc(1, sizeof(struct IMAP));
|
||||
imap = curlx_calloc(1, sizeof(struct IMAP));
|
||||
if(!imap ||
|
||||
Curl_meta_set(data, CURL_META_IMAP_EASY, imap, imap_easy_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -2078,7 +2074,7 @@ static char *imap_atom(const char *str, bool escape_only)
|
|||
nclean = strcspn(str, "() {%*]\\\"");
|
||||
if(len == nclean)
|
||||
/* nothing to escape, return a strdup */
|
||||
return strdup(str);
|
||||
return curlx_strdup(str);
|
||||
|
||||
curlx_dyn_init(&line, 2000);
|
||||
|
||||
|
|
@ -2258,7 +2254,7 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data,
|
|||
result = Curl_urldecode(begin, ptr - begin, &value, &valuelen,
|
||||
REJECT_CTRL);
|
||||
if(result) {
|
||||
free(name);
|
||||
curlx_free(name);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -2279,7 +2275,7 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data,
|
|||
imap->uidvalidity = (unsigned int)num;
|
||||
imap->uidvalidity_set = TRUE;
|
||||
}
|
||||
free(value);
|
||||
curlx_free(value);
|
||||
}
|
||||
else if(curl_strequal(name, "UID") && !imap->uid) {
|
||||
imap->uid = value;
|
||||
|
|
@ -2294,15 +2290,15 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data,
|
|||
imap->partial = value;
|
||||
}
|
||||
else {
|
||||
free(name);
|
||||
free(value);
|
||||
curlx_free(name);
|
||||
curlx_free(value);
|
||||
return CURLE_URL_MALFORMAT;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* blank? */
|
||||
free(value);
|
||||
free(name);
|
||||
curlx_free(value);
|
||||
curlx_free(name);
|
||||
}
|
||||
|
||||
/* Does the URL contain a query parameter? Only valid when we have a mailbox
|
||||
|
|
@ -2346,7 +2342,7 @@ static CURLcode imap_parse_custom_request(struct Curl_easy *data,
|
|||
params++;
|
||||
|
||||
if(*params) {
|
||||
imap->custom_params = strdup(params);
|
||||
imap->custom_params = curlx_strdup(params);
|
||||
imap->custom[params - imap->custom] = '\0';
|
||||
|
||||
if(!imap->custom_params)
|
||||
|
|
|
|||
38
lib/ldap.c
38
lib/ldap.c
|
|
@ -94,10 +94,6 @@
|
|||
#include "curlx/base64.h"
|
||||
#include "connect.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef USE_WIN32_LDAP
|
||||
#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
|
||||
#define curl_ldap_num_t ULONG
|
||||
|
|
@ -642,7 +638,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
|
|||
if(val_b64_sz > 0) {
|
||||
result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64,
|
||||
val_b64_sz);
|
||||
free(val_b64);
|
||||
curlx_free(val_b64);
|
||||
if(result) {
|
||||
ldap_value_free_len(vals);
|
||||
FREE_ON_WINLDAP(attr);
|
||||
|
|
@ -809,15 +805,15 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
ludp->lud_host = conn->host.name;
|
||||
|
||||
/* Duplicate the path */
|
||||
p = path = strdup(data->state.up.path + 1);
|
||||
p = path = curlx_strdup(data->state.up.path + 1);
|
||||
if(!path)
|
||||
return LDAP_NO_MEMORY;
|
||||
|
||||
/* Duplicate the query if present */
|
||||
if(data->state.up.query) {
|
||||
q = query = strdup(data->state.up.query);
|
||||
q = query = curlx_strdup(data->state.up.query);
|
||||
if(!query) {
|
||||
free(path);
|
||||
curlx_free(path);
|
||||
return LDAP_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
|
@ -843,7 +839,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
ludp->lud_dn = curlx_convert_UTF8_to_tchar(unescaped);
|
||||
|
||||
/* Free the unescaped string as we are done with it */
|
||||
free(unescaped);
|
||||
curlx_free(unescaped);
|
||||
|
||||
if(!ludp->lud_dn) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
|
|
@ -870,9 +866,9 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
|
||||
/* Allocate our array (+1 for the NULL entry) */
|
||||
#ifdef USE_WIN32_LDAP
|
||||
ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
|
||||
ludp->lud_attrs = curlx_calloc(count + 1, sizeof(TCHAR *));
|
||||
#else
|
||||
ludp->lud_attrs = calloc(count + 1, sizeof(char *));
|
||||
ludp->lud_attrs = curlx_calloc(count + 1, sizeof(char *));
|
||||
#endif
|
||||
if(!ludp->lud_attrs) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
|
|
@ -902,7 +898,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
ludp->lud_attrs[i] = curlx_convert_UTF8_to_tchar(unescaped);
|
||||
|
||||
/* Free the unescaped string as we are done with it */
|
||||
free(unescaped);
|
||||
curlx_free(unescaped);
|
||||
|
||||
if(!ludp->lud_attrs[i]) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
|
|
@ -966,7 +962,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
ludp->lud_filter = curlx_convert_UTF8_to_tchar(unescaped);
|
||||
|
||||
/* Free the unescaped string as we are done with it */
|
||||
free(unescaped);
|
||||
curlx_free(unescaped);
|
||||
|
||||
if(!ludp->lud_filter) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
|
|
@ -986,8 +982,8 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
|
|||
}
|
||||
|
||||
quit:
|
||||
free(path);
|
||||
free(query);
|
||||
curlx_free(path);
|
||||
curlx_free(query);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -996,7 +992,7 @@ static curl_ldap_num_t ldap_url_parse_low(struct Curl_easy *data,
|
|||
const struct connectdata *conn,
|
||||
LDAPURLDesc **ludpp)
|
||||
{
|
||||
LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
|
||||
LDAPURLDesc *ludp = curlx_calloc(1, sizeof(*ludp));
|
||||
curl_ldap_num_t rc;
|
||||
|
||||
*ludpp = NULL;
|
||||
|
|
@ -1021,8 +1017,8 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp)
|
|||
curlx_unicodefree(ludp->lud_dn);
|
||||
curlx_unicodefree(ludp->lud_filter);
|
||||
#else
|
||||
free(ludp->lud_dn);
|
||||
free(ludp->lud_filter);
|
||||
curlx_free(ludp->lud_dn);
|
||||
curlx_free(ludp->lud_filter);
|
||||
#endif
|
||||
|
||||
if(ludp->lud_attrs) {
|
||||
|
|
@ -1031,13 +1027,13 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp)
|
|||
#ifdef USE_WIN32_LDAP
|
||||
curlx_unicodefree(ludp->lud_attrs[i]);
|
||||
#else
|
||||
free(ludp->lud_attrs[i]);
|
||||
curlx_free(ludp->lud_attrs[i]);
|
||||
#endif
|
||||
}
|
||||
free(ludp->lud_attrs);
|
||||
curlx_free(ludp->lud_attrs);
|
||||
}
|
||||
|
||||
free(ludp);
|
||||
curlx_free(ludp);
|
||||
}
|
||||
#endif /* !HAVE_LDAP_URL_PARSE */
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include "llist.h"
|
||||
#include "curl_memory.h"
|
||||
|
||||
/* this must be the last include file */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
#define LLISTINIT 0x100cc001 /* random pattern */
|
||||
|
|
|
|||
|
|
@ -71,10 +71,6 @@
|
|||
#include <nettle/md4.h>
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4)
|
||||
|
||||
|
|
|
|||
18
lib/md5.c
18
lib/md5.c
|
|
@ -81,10 +81,6 @@
|
|||
#include <wincrypt.h>
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef USE_GNUTLS
|
||||
|
||||
typedef struct md5_ctx my_md5_ctx;
|
||||
|
|
@ -604,23 +600,23 @@ struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
|
|||
struct MD5_context *ctxt;
|
||||
|
||||
/* Create MD5 context */
|
||||
ctxt = malloc(sizeof(*ctxt));
|
||||
ctxt = curlx_malloc(sizeof(*ctxt));
|
||||
|
||||
if(!ctxt)
|
||||
return ctxt;
|
||||
|
||||
ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize);
|
||||
ctxt->md5_hashctx = curlx_malloc(md5params->md5_ctxtsize);
|
||||
|
||||
if(!ctxt->md5_hashctx) {
|
||||
free(ctxt);
|
||||
curlx_free(ctxt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctxt->md5_hash = md5params;
|
||||
|
||||
if((*md5params->md5_init_func)(ctxt->md5_hashctx)) {
|
||||
free(ctxt->md5_hashctx);
|
||||
free(ctxt);
|
||||
curlx_free(ctxt->md5_hashctx);
|
||||
curlx_free(ctxt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -640,8 +636,8 @@ CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result)
|
|||
{
|
||||
(*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
|
||||
|
||||
free(context->md5_hashctx);
|
||||
free(context);
|
||||
curlx_free(context->md5_hashctx);
|
||||
curlx_free(context);
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,6 @@
|
|||
#include "backtrace.h"
|
||||
#endif
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
struct memdebug {
|
||||
size_t size;
|
||||
union {
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
#ifndef HEADER_CURL_MEMDEBUG_H
|
||||
#define HEADER_CURL_MEMDEBUG_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* CAUTION: this header is designed to work when included by the app-side
|
||||
* as well as the library. Do not mix with library internals!
|
||||
*/
|
||||
|
||||
#ifdef CURLDEBUG
|
||||
|
||||
/* Set this symbol on the command-line, recompile all lib-sources */
|
||||
#undef strdup
|
||||
#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
|
||||
#undef malloc
|
||||
#define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
|
||||
#undef calloc
|
||||
#define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
|
||||
#undef realloc
|
||||
#define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
|
||||
#undef free
|
||||
#define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef Curl_tcsdup
|
||||
#ifdef UNICODE
|
||||
#define Curl_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
|
||||
#else
|
||||
#define Curl_tcsdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* CURLDEBUG */
|
||||
#endif /* HEADER_CURL_MEMDEBUG_H */
|
||||
34
lib/mime.c
34
lib/mime.c
|
|
@ -50,10 +50,6 @@ struct Curl_easy;
|
|||
#include "slist.h"
|
||||
#include "curlx/dynbuf.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef R_OK
|
||||
# define R_OK 4
|
||||
|
|
@ -357,13 +353,13 @@ static char *strippath(const char *fullfile)
|
|||
{
|
||||
char *filename;
|
||||
char *base;
|
||||
filename = strdup(fullfile); /* duplicate since basename() may ruin the
|
||||
buffer it works on */
|
||||
filename = curlx_strdup(fullfile); /* duplicate since basename() may ruin
|
||||
the buffer it works on */
|
||||
if(!filename)
|
||||
return NULL;
|
||||
base = strdup(basename(filename));
|
||||
base = curlx_strdup(basename(filename));
|
||||
|
||||
free(filename); /* free temporary buffer */
|
||||
curlx_free(filename); /* free temporary buffer */
|
||||
|
||||
return base; /* returns an allocated string or NULL ! */
|
||||
}
|
||||
|
|
@ -1190,9 +1186,9 @@ void curl_mime_free(curl_mime *mime)
|
|||
part = mime->firstpart;
|
||||
mime->firstpart = part->nextpart;
|
||||
Curl_mime_cleanpart(part);
|
||||
free(part);
|
||||
curlx_free(part);
|
||||
}
|
||||
free(mime);
|
||||
curlx_free(mime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1282,7 +1278,7 @@ curl_mime *curl_mime_init(void *easy)
|
|||
{
|
||||
curl_mime *mime;
|
||||
|
||||
mime = (curl_mime *) malloc(sizeof(*mime));
|
||||
mime = (curl_mime *)curlx_malloc(sizeof(*mime));
|
||||
|
||||
if(mime) {
|
||||
mime->parent = NULL;
|
||||
|
|
@ -1294,7 +1290,7 @@ curl_mime *curl_mime_init(void *easy)
|
|||
(unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES],
|
||||
MIME_RAND_BOUNDARY_CHARS + 1)) {
|
||||
/* failed to get random separator, bail out */
|
||||
free(mime);
|
||||
curlx_free(mime);
|
||||
return NULL;
|
||||
}
|
||||
mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
|
||||
|
|
@ -1319,7 +1315,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime)
|
|||
if(!mime)
|
||||
return NULL;
|
||||
|
||||
part = (curl_mimepart *) malloc(sizeof(*part));
|
||||
part = (curl_mimepart *)curlx_malloc(sizeof(*part));
|
||||
|
||||
if(part) {
|
||||
Curl_mime_initpart(part);
|
||||
|
|
@ -1345,7 +1341,7 @@ CURLcode curl_mime_name(curl_mimepart *part, const char *name)
|
|||
Curl_safefree(part->name);
|
||||
|
||||
if(name) {
|
||||
part->name = strdup(name);
|
||||
part->name = curlx_strdup(name);
|
||||
if(!part->name)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -1362,7 +1358,7 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
|
|||
Curl_safefree(part->filename);
|
||||
|
||||
if(filename) {
|
||||
part->filename = strdup(filename);
|
||||
part->filename = curlx_strdup(filename);
|
||||
if(!part->filename)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -1415,7 +1411,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
|||
if(curlx_stat(filename, &sbuf))
|
||||
result = CURLE_READ_ERROR;
|
||||
else {
|
||||
part->data = strdup(filename);
|
||||
part->data = curlx_strdup(filename);
|
||||
if(!part->data)
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
|
|
@ -1438,7 +1434,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
|||
result = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
result = curl_mime_filename(part, base);
|
||||
free(base);
|
||||
curlx_free(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1455,7 +1451,7 @@ CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
|
|||
Curl_safefree(part->mimetype);
|
||||
|
||||
if(mimetype) {
|
||||
part->mimetype = strdup(mimetype);
|
||||
part->mimetype = curlx_strdup(mimetype);
|
||||
if(!part->mimetype)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -1696,7 +1692,7 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
|
|||
if(hdr)
|
||||
*slp = hdr;
|
||||
else
|
||||
free(s);
|
||||
curlx_free(s);
|
||||
}
|
||||
|
||||
return hdr ? CURLE_OK : CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
#include "curl_printf.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef HAVE_LONGLONG
|
||||
# define LONG_LONG_TYPE long long
|
||||
# define HAVE_LONG_LONG_TYPE
|
||||
|
|
@ -1177,7 +1173,7 @@ char *curl_mvaprintf(const char *format, va_list ap_save)
|
|||
}
|
||||
if(curlx_dyn_len(info.b))
|
||||
return curlx_dyn_ptr(info.b);
|
||||
return strdup("");
|
||||
return curlx_strdup("");
|
||||
}
|
||||
|
||||
char *curl_maprintf(const char *format, ...)
|
||||
|
|
|
|||
28
lib/mqtt.c
28
lib/mqtt.c
|
|
@ -40,10 +40,6 @@
|
|||
#include "multiif.h"
|
||||
#include "rand.h"
|
||||
|
||||
/* The last 2 #includes file should be: */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* first byte is command.
|
||||
second byte is for flags. */
|
||||
#define MQTT_MSG_CONNECT 0x10
|
||||
|
|
@ -146,14 +142,14 @@ static void mqtt_easy_dtor(void *key, size_t klen, void *entry)
|
|||
(void)klen;
|
||||
curlx_dyn_free(&mq->sendbuf);
|
||||
curlx_dyn_free(&mq->recvbuf);
|
||||
free(mq);
|
||||
curlx_free(mq);
|
||||
}
|
||||
|
||||
static void mqtt_conn_dtor(void *key, size_t klen, void *entry)
|
||||
{
|
||||
(void)key;
|
||||
(void)klen;
|
||||
free(entry);
|
||||
curlx_free(entry);
|
||||
}
|
||||
|
||||
static CURLcode mqtt_setup_conn(struct Curl_easy *data,
|
||||
|
|
@ -163,12 +159,12 @@ static CURLcode mqtt_setup_conn(struct Curl_easy *data,
|
|||
struct mqtt_conn *mqtt;
|
||||
struct MQTT *mq;
|
||||
|
||||
mqtt = calloc(1, sizeof(*mqtt));
|
||||
mqtt = curlx_calloc(1, sizeof(*mqtt));
|
||||
if(!mqtt ||
|
||||
Curl_conn_meta_set(conn, CURL_META_MQTT_CONN, mqtt, mqtt_conn_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
mq = calloc(1, sizeof(struct MQTT));
|
||||
mq = curlx_calloc(1, sizeof(struct MQTT));
|
||||
if(!mq)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
curlx_dyn_init(&mq->recvbuf, DYN_MQTT_RECV);
|
||||
|
|
@ -350,7 +346,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data)
|
|||
/* allocating packet */
|
||||
if(packetlen > 0xFFFFFFF)
|
||||
return CURLE_WEIRD_SERVER_REPLY;
|
||||
packet = calloc(1, packetlen);
|
||||
packet = curlx_calloc(1, packetlen);
|
||||
if(!packet)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -400,7 +396,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data)
|
|||
|
||||
end:
|
||||
if(packet)
|
||||
free(packet);
|
||||
curlx_free(packet);
|
||||
Curl_safefree(data->state.aptr.user);
|
||||
Curl_safefree(data->state.aptr.passwd);
|
||||
return result;
|
||||
|
|
@ -524,7 +520,7 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data)
|
|||
n = mqtt_encode_len((char *)encodedsize, packetlen);
|
||||
packetlen += n + 1; /* add one for the control packet type byte */
|
||||
|
||||
packet = malloc(packetlen);
|
||||
packet = curlx_malloc(packetlen);
|
||||
if(!packet) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -542,8 +538,8 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data)
|
|||
result = mqtt_send(data, (const char *)packet, packetlen);
|
||||
|
||||
fail:
|
||||
free(topic);
|
||||
free(packet);
|
||||
curlx_free(topic);
|
||||
curlx_free(packet);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -620,7 +616,7 @@ static CURLcode mqtt_publish(struct Curl_easy *data)
|
|||
}
|
||||
|
||||
/* add the control byte and the encoded remaining length */
|
||||
pkt = malloc(remaininglength + 1 + encodelen);
|
||||
pkt = curlx_malloc(remaininglength + 1 + encodelen);
|
||||
if(!pkt) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto fail;
|
||||
|
|
@ -639,8 +635,8 @@ static CURLcode mqtt_publish(struct Curl_easy *data)
|
|||
result = mqtt_send(data, (const char *)pkt, i);
|
||||
|
||||
fail:
|
||||
free(pkt);
|
||||
free(topic);
|
||||
curlx_free(pkt);
|
||||
curlx_free(topic);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
34
lib/multi.c
34
lib/multi.c
|
|
@ -54,10 +54,6 @@
|
|||
#include "socks.h"
|
||||
#include "urlapi-int.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* initial multi->xfers table size for a full multi */
|
||||
#define CURL_XFER_TABLE_SIZE 512
|
||||
|
||||
|
|
@ -235,7 +231,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
|
|||
size_t dnssize, /* dns hash */
|
||||
size_t sesssize) /* TLS session cache */
|
||||
{
|
||||
struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi));
|
||||
struct Curl_multi *multi = curlx_calloc(1, sizeof(struct Curl_multi));
|
||||
|
||||
if(!multi)
|
||||
return NULL;
|
||||
|
|
@ -328,7 +324,7 @@ error:
|
|||
Curl_uint32_bset_destroy(&multi->msgsent);
|
||||
Curl_uint32_tbl_destroy(&multi->xfers);
|
||||
|
||||
free(multi);
|
||||
curlx_free(multi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -2022,7 +2018,7 @@ static CURLMcode state_performing(struct Curl_easy *data,
|
|||
data->state.errorbuf = FALSE;
|
||||
if(!newurl)
|
||||
/* typically for HTTP_1_1_REQUIRED error on first flight */
|
||||
newurl = strdup(data->state.url);
|
||||
newurl = curlx_strdup(data->state.url);
|
||||
if(!newurl) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
@ -2068,7 +2064,7 @@ static CURLMcode state_performing(struct Curl_easy *data,
|
|||
if(!retry) {
|
||||
/* if the URL is a follow-location and not just a retried request then
|
||||
figure out the URL here */
|
||||
free(newurl);
|
||||
curlx_free(newurl);
|
||||
newurl = data->req.newurl;
|
||||
data->req.newurl = NULL;
|
||||
follow = FOLLOW_REDIR;
|
||||
|
|
@ -2089,7 +2085,7 @@ static CURLMcode state_performing(struct Curl_easy *data,
|
|||
/* but first check to see if we got a location info even though we are
|
||||
not following redirects */
|
||||
if(data->req.location) {
|
||||
free(newurl);
|
||||
curlx_free(newurl);
|
||||
newurl = data->req.location;
|
||||
data->req.location = NULL;
|
||||
result = multi_follow(data, handler, newurl, FOLLOW_FAKE);
|
||||
|
|
@ -2109,7 +2105,7 @@ static CURLMcode state_performing(struct Curl_easy *data,
|
|||
*nowp = curlx_now();
|
||||
mspeed_check(data, *nowp);
|
||||
}
|
||||
free(newurl);
|
||||
curlx_free(newurl);
|
||||
*resultp = result;
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -2237,7 +2233,7 @@ static CURLMcode state_do(struct Curl_easy *data,
|
|||
/* Have error handler disconnect conn if we cannot retry */
|
||||
*stream_errorp = TRUE;
|
||||
}
|
||||
free(newurl);
|
||||
curlx_free(newurl);
|
||||
}
|
||||
else {
|
||||
/* failure detected */
|
||||
|
|
@ -2976,7 +2972,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
|
|||
Curl_uint32_bset_destroy(&multi->pending);
|
||||
Curl_uint32_bset_destroy(&multi->msgsent);
|
||||
Curl_uint32_tbl_destroy(&multi->xfers);
|
||||
free(multi);
|
||||
curlx_free(multi);
|
||||
|
||||
return CURLM_OK;
|
||||
}
|
||||
|
|
@ -3814,7 +3810,7 @@ CURL **curl_multi_get_handles(CURLM *m)
|
|||
struct Curl_multi *multi = m;
|
||||
void *entry;
|
||||
unsigned int count = Curl_uint32_tbl_count(&multi->xfers);
|
||||
CURL **a = malloc(sizeof(struct Curl_easy *) * (count + 1));
|
||||
CURL **a = curlx_malloc(sizeof(struct Curl_easy *) * (count + 1));
|
||||
if(a) {
|
||||
unsigned int i = 0, mid;
|
||||
|
||||
|
|
@ -3895,13 +3891,13 @@ CURLcode Curl_multi_xfer_buf_borrow(struct Curl_easy *data,
|
|||
if(data->multi->xfer_buf &&
|
||||
data->set.buffer_size > data->multi->xfer_buf_len) {
|
||||
/* not large enough, get a new one */
|
||||
free(data->multi->xfer_buf);
|
||||
curlx_free(data->multi->xfer_buf);
|
||||
data->multi->xfer_buf = NULL;
|
||||
data->multi->xfer_buf_len = 0;
|
||||
}
|
||||
|
||||
if(!data->multi->xfer_buf) {
|
||||
data->multi->xfer_buf = malloc(curlx_uitouz(data->set.buffer_size));
|
||||
data->multi->xfer_buf = curlx_malloc(curlx_uitouz(data->set.buffer_size));
|
||||
if(!data->multi->xfer_buf) {
|
||||
failf(data, "could not allocate xfer_buf of %u bytes",
|
||||
data->set.buffer_size);
|
||||
|
|
@ -3948,14 +3944,14 @@ CURLcode Curl_multi_xfer_ulbuf_borrow(struct Curl_easy *data,
|
|||
if(data->multi->xfer_ulbuf &&
|
||||
data->set.upload_buffer_size > data->multi->xfer_ulbuf_len) {
|
||||
/* not large enough, get a new one */
|
||||
free(data->multi->xfer_ulbuf);
|
||||
curlx_free(data->multi->xfer_ulbuf);
|
||||
data->multi->xfer_ulbuf = NULL;
|
||||
data->multi->xfer_ulbuf_len = 0;
|
||||
}
|
||||
|
||||
if(!data->multi->xfer_ulbuf) {
|
||||
data->multi->xfer_ulbuf =
|
||||
malloc(curlx_uitouz(data->set.upload_buffer_size));
|
||||
curlx_malloc(curlx_uitouz(data->set.upload_buffer_size));
|
||||
if(!data->multi->xfer_ulbuf) {
|
||||
failf(data, "could not allocate xfer_ulbuf of %u bytes",
|
||||
data->set.upload_buffer_size);
|
||||
|
|
@ -3996,13 +3992,13 @@ CURLcode Curl_multi_xfer_sockbuf_borrow(struct Curl_easy *data,
|
|||
|
||||
if(data->multi->xfer_sockbuf && blen > data->multi->xfer_sockbuf_len) {
|
||||
/* not large enough, get a new one */
|
||||
free(data->multi->xfer_sockbuf);
|
||||
curlx_free(data->multi->xfer_sockbuf);
|
||||
data->multi->xfer_sockbuf = NULL;
|
||||
data->multi->xfer_sockbuf_len = 0;
|
||||
}
|
||||
|
||||
if(!data->multi->xfer_sockbuf) {
|
||||
data->multi->xfer_sockbuf = malloc(blen);
|
||||
data->multi->xfer_sockbuf = curlx_malloc(blen);
|
||||
if(!data->multi->xfer_sockbuf) {
|
||||
failf(data, "could not allocate xfer_sockbuf of %zu bytes", blen);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@
|
|||
#include "multihandle.h"
|
||||
#include "socks.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
static void mev_in_callback(struct Curl_multi *multi, bool value)
|
||||
{
|
||||
|
|
@ -85,7 +81,7 @@ static void mev_sh_entry_dtor(void *freethis)
|
|||
{
|
||||
struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
|
||||
Curl_uint32_spbset_destroy(&entry->xfers);
|
||||
free(entry);
|
||||
curlx_free(entry);
|
||||
}
|
||||
|
||||
/* look up a given socket in the socket hash, skip invalid sockets */
|
||||
|
|
@ -112,7 +108,7 @@ mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s)
|
|||
}
|
||||
|
||||
/* not present, add it */
|
||||
check = calloc(1, sizeof(struct mev_sh_entry));
|
||||
check = curlx_calloc(1, sizeof(struct mev_sh_entry));
|
||||
if(!check)
|
||||
return NULL; /* major failure */
|
||||
|
||||
|
|
@ -446,7 +442,7 @@ static void mev_pollset_dtor(void *key, size_t klen, void *entry)
|
|||
(void)klen;
|
||||
if(ps) {
|
||||
Curl_pollset_cleanup(ps);
|
||||
free(ps);
|
||||
curlx_free(ps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,6 @@
|
|||
#include "multiif.h"
|
||||
#include "multi_ntfy.h"
|
||||
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
struct mntfy_entry {
|
||||
uint32_t mid;
|
||||
|
|
@ -54,12 +49,12 @@ struct mntfy_chunk {
|
|||
|
||||
static struct mntfy_chunk *mnfty_chunk_create(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct mntfy_chunk));
|
||||
return curlx_calloc(1, sizeof(struct mntfy_chunk));
|
||||
}
|
||||
|
||||
static void mnfty_chunk_destroy(struct mntfy_chunk *chunk)
|
||||
{
|
||||
free(chunk);
|
||||
curlx_free(chunk);
|
||||
}
|
||||
|
||||
static void mnfty_chunk_reset(struct mntfy_chunk *chunk)
|
||||
|
|
|
|||
28
lib/netrc.c
28
lib/netrc.c
|
|
@ -42,10 +42,6 @@
|
|||
#include "curlx/fopen.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Get user and password from .netrc when given a machine name */
|
||||
|
||||
enum host_lookup_state {
|
||||
|
|
@ -277,8 +273,8 @@ static NETRCcode parsenetrc(struct store_netrc *store,
|
|||
our_login = !Curl_timestrcmp(login, tok);
|
||||
else {
|
||||
our_login = TRUE;
|
||||
free(login);
|
||||
login = strdup(tok);
|
||||
curlx_free(login);
|
||||
login = curlx_strdup(tok);
|
||||
if(!login) {
|
||||
retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */
|
||||
goto out;
|
||||
|
|
@ -288,8 +284,8 @@ static NETRCcode parsenetrc(struct store_netrc *store,
|
|||
keyword = NONE;
|
||||
}
|
||||
else if(keyword == PASSWORD) {
|
||||
free(password);
|
||||
password = strdup(tok);
|
||||
curlx_free(password);
|
||||
password = curlx_strdup(tok);
|
||||
if(!password) {
|
||||
retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */
|
||||
goto out;
|
||||
|
|
@ -346,7 +342,7 @@ out:
|
|||
if(!retcode) {
|
||||
if(!password && our_login) {
|
||||
/* success without a password, set a blank one */
|
||||
password = strdup("");
|
||||
password = curlx_strdup("");
|
||||
if(!password)
|
||||
retcode = NETRC_OUT_OF_MEMORY; /* out of memory */
|
||||
}
|
||||
|
|
@ -364,8 +360,8 @@ out:
|
|||
curlx_dyn_free(filebuf);
|
||||
store->loaded = FALSE;
|
||||
if(!specific_login)
|
||||
free(login);
|
||||
free(password);
|
||||
curlx_free(login);
|
||||
curlx_free(password);
|
||||
}
|
||||
|
||||
return retcode;
|
||||
|
|
@ -444,25 +440,25 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host,
|
|||
|
||||
filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR);
|
||||
if(!filealloc) {
|
||||
free(homea);
|
||||
curlx_free(homea);
|
||||
return NETRC_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
retcode = parsenetrc(store, host, loginp, passwordp, filealloc);
|
||||
free(filealloc);
|
||||
curlx_free(filealloc);
|
||||
#ifdef _WIN32
|
||||
if(retcode == NETRC_FILE_MISSING) {
|
||||
/* fallback to the old-style "_netrc" file */
|
||||
filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR);
|
||||
if(!filealloc) {
|
||||
free(homea);
|
||||
curlx_free(homea);
|
||||
return NETRC_OUT_OF_MEMORY;
|
||||
}
|
||||
retcode = parsenetrc(store, host, loginp, passwordp, filealloc);
|
||||
free(filealloc);
|
||||
curlx_free(filealloc);
|
||||
}
|
||||
#endif
|
||||
free(homea);
|
||||
curlx_free(homea);
|
||||
}
|
||||
else
|
||||
retcode = parsenetrc(store, host, loginp, passwordp, netrcfile);
|
||||
|
|
|
|||
|
|
@ -53,10 +53,6 @@
|
|||
#include "curl_sasl.h"
|
||||
#include "strcase.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Uncommenting this will enable the built-in debug logging of the openldap
|
||||
* library. The debug log level can be set using the CURL_OPENLDAP_TRACE
|
||||
|
|
@ -577,7 +573,7 @@ static void oldap_easy_dtor(void *key, size_t klen, void *entry)
|
|||
struct ldapreqinfo *lr = entry;
|
||||
(void)key;
|
||||
(void)klen;
|
||||
free(lr);
|
||||
curlx_free(lr);
|
||||
}
|
||||
|
||||
static void oldap_conn_dtor(void *key, size_t klen, void *entry)
|
||||
|
|
@ -589,7 +585,7 @@ static void oldap_conn_dtor(void *key, size_t klen, void *entry)
|
|||
ldap_unbind_ext(li->ld, NULL, NULL);
|
||||
li->ld = NULL;
|
||||
}
|
||||
free(li);
|
||||
curlx_free(li);
|
||||
}
|
||||
|
||||
static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
|
||||
|
|
@ -606,7 +602,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
|
|||
|
||||
(void)done;
|
||||
|
||||
li = calloc(1, sizeof(struct ldapconninfo));
|
||||
li = curlx_calloc(1, sizeof(struct ldapconninfo));
|
||||
if(!li) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
|
|
@ -697,7 +693,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
|
|||
result = oldap_perform_bind(data, OLDAP_BIND);
|
||||
|
||||
out:
|
||||
free(hosturl);
|
||||
curlx_free(hosturl);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1023,7 +1019,7 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done)
|
|||
goto out;
|
||||
}
|
||||
|
||||
lr = calloc(1, sizeof(struct ldapreqinfo));
|
||||
lr = curlx_calloc(1, sizeof(struct ldapreqinfo));
|
||||
if(!lr ||
|
||||
Curl_meta_set(data, CURL_META_LDAP_EASY, lr, oldap_easy_dtor)) {
|
||||
ldap_abandon_ext(li->ld, msgid, NULL, NULL);
|
||||
|
|
@ -1219,7 +1215,7 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf,
|
|||
if(!result)
|
||||
result = client_write(data, STRCONST(": "), val_b64, val_b64_sz,
|
||||
STRCONST("\n"));
|
||||
free(val_b64);
|
||||
curlx_free(val_b64);
|
||||
}
|
||||
else
|
||||
result = client_write(data, STRCONST(" "),
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
#include "multiif.h"
|
||||
#include "vtls/vtls.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef USE_PINGPONG
|
||||
|
||||
/* Returns timeout in ms. 0 or negative number means the timeout has already
|
||||
|
|
|
|||
12
lib/pop3.c
12
lib/pop3.c
|
|
@ -78,10 +78,6 @@
|
|||
#include "curlx/warnless.h"
|
||||
#include "strdup.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Authentication type flags */
|
||||
#define POP3_TYPE_CLEARTEXT (1 << 0)
|
||||
#define POP3_TYPE_APOP (1 << 1)
|
||||
|
|
@ -1523,7 +1519,7 @@ static void pop3_easy_dtor(void *key, size_t klen, void *entry)
|
|||
/* Cleanup our per-request based variables */
|
||||
Curl_safefree(pop3->id);
|
||||
Curl_safefree(pop3->custom);
|
||||
free(pop3);
|
||||
curlx_free(pop3);
|
||||
}
|
||||
|
||||
static void pop3_conn_dtor(void *key, size_t klen, void *entry)
|
||||
|
|
@ -1534,19 +1530,19 @@ static void pop3_conn_dtor(void *key, size_t klen, void *entry)
|
|||
DEBUGASSERT(pop3c);
|
||||
Curl_pp_disconnect(&pop3c->pp);
|
||||
Curl_safefree(pop3c->apoptimestamp);
|
||||
free(pop3c);
|
||||
curlx_free(pop3c);
|
||||
}
|
||||
|
||||
static CURLcode pop3_setup_connection(struct Curl_easy *data,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
struct pop3_conn *pop3c;
|
||||
struct POP3 *pop3 = calloc(1, sizeof(*pop3));
|
||||
struct POP3 *pop3 = curlx_calloc(1, sizeof(*pop3));
|
||||
if(!pop3 ||
|
||||
Curl_meta_set(data, CURL_META_POP3_EASY, pop3, pop3_easy_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
pop3c = calloc(1, sizeof(*pop3c));
|
||||
pop3c = curlx_calloc(1, sizeof(*pop3c));
|
||||
if(!pop3c ||
|
||||
Curl_conn_meta_set(conn, CURL_META_POP3_CONN, pop3c, pop3_conn_dtor))
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
#include "psl.h"
|
||||
#include "curl_share.h"
|
||||
|
||||
/* The last 2 #include files should be in this order */
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
void Curl_psl_destroy(struct PslCache *pslcache)
|
||||
{
|
||||
if(pslcache->psl) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue