mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x)
This makes the code more readable and less prone to copy-paste errors. In addition, it allows to place some __builtin_constant_p() predicates to trigger a link-time error in case the compiler knows that the freed area is constant. It will also produce compile-time error if trying to free something that is not a regular pointer (e.g. a function). The DEBUG_MEM_STATS macro now also defines an instance for ha_free() so that all these calls can be checked. 178 occurrences were converted. The vast majority of them were handled by the following Coccinelle script, some slightly refined to better deal with "&*x" or with long lines: @ rule @ expression E; @@ - free(E); - E = NULL; + ha_free(&E); It was verified that the resulting code is the same, more or less a handful of cases where the compiler optimized slightly differently the temporary variable that holds the copy of the pointer. A non-negligible amount of {free(str);str=NULL;str_len=0;} are still present in the config part (mostly header names in proxies). These ones should also be cleaned for the same reasons, and probably be turned into ist strings.
This commit is contained in:
parent
ee17b97eea
commit
61cfdf4fd8
@ -73,6 +73,17 @@
|
||||
#define BUG_ON(cond)
|
||||
#endif
|
||||
|
||||
/* more reliable free() that clears the pointer */
|
||||
#define ha_free(x) do { \
|
||||
typeof(x) __x = (x); \
|
||||
if (__builtin_constant_p((x)) || __builtin_constant_p(*(x))) { \
|
||||
/* provoke a build-time error */ \
|
||||
extern volatile int call_to_ha_free_attempts_to_free_a_constant; \
|
||||
call_to_ha_free_attempts_to_free_a_constant = 1; \
|
||||
} \
|
||||
free(*__x); \
|
||||
*__x = NULL; \
|
||||
} while (0)
|
||||
|
||||
#if defined(DEBUG_MEM_STATS)
|
||||
#include <stdlib.h>
|
||||
@ -129,6 +140,26 @@ struct mem_stats {
|
||||
free(__x); \
|
||||
})
|
||||
|
||||
#undef ha_free
|
||||
#define ha_free(x) ({ \
|
||||
typeof(x) __x = (x); \
|
||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
||||
.file = __FILE__, .line = __LINE__, \
|
||||
.type = MEM_STATS_TYPE_FREE, \
|
||||
}; \
|
||||
__asm__(".globl __start_mem_stats"); \
|
||||
__asm__(".globl __stop_mem_stats"); \
|
||||
if (__builtin_constant_p((x)) || __builtin_constant_p(*(x))) { \
|
||||
/* provoke a build-time error */ \
|
||||
extern volatile int call_to_ha_free_attempts_to_free_a_constant; \
|
||||
call_to_ha_free_attempts_to_free_a_constant = 1; \
|
||||
} \
|
||||
if (*__x) \
|
||||
_HA_ATOMIC_ADD(&_.calls, 1); \
|
||||
free(*__x); \
|
||||
*__x = NULL; \
|
||||
})
|
||||
|
||||
#undef malloc
|
||||
#define malloc(x) ({ \
|
||||
size_t __x = (x); \
|
||||
|
@ -728,7 +728,7 @@ static void deinit_51degrees(void)
|
||||
#endif
|
||||
fiftyoneDegreesDataSetFree(&global_51degrees.data_set);
|
||||
|
||||
free(global_51degrees.data_file_path); global_51degrees.data_file_path = NULL;
|
||||
ha_free(&global_51degrees.data_file_path);
|
||||
list_for_each_entry_safe(_51d_prop_name, _51d_prop_nameb, &global_51degrees.property_names, list) {
|
||||
LIST_DEL(&_51d_prop_name->list);
|
||||
free(_51d_prop_name);
|
||||
|
@ -305,8 +305,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
|
||||
goto out_free_smp;
|
||||
}
|
||||
}
|
||||
free(ckw);
|
||||
ckw = NULL;
|
||||
ha_free(&ckw);
|
||||
}
|
||||
else {
|
||||
/* This is not an ACL keyword, so we hope this is a sample fetch
|
||||
|
@ -399,8 +399,7 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
|
||||
* in between, there is no arg at all.
|
||||
*/
|
||||
if (!pos) {
|
||||
free(*argp);
|
||||
*argp = NULL;
|
||||
ha_free(argp);
|
||||
}
|
||||
|
||||
if (pos >= min_arg)
|
||||
|
@ -199,8 +199,7 @@ int userlist_postinit()
|
||||
curuser->u.groups = grl;
|
||||
}
|
||||
|
||||
free(ag->groupusers);
|
||||
ag->groupusers = NULL;
|
||||
ha_free(&ag->groupusers);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_AUTH
|
||||
|
@ -2058,8 +2058,7 @@ int cfg_post_parse_section_cache()
|
||||
return err_code;
|
||||
}
|
||||
out:
|
||||
free(tmp_cache_config);
|
||||
tmp_cache_config = NULL;
|
||||
ha_free(&tmp_cache_config);
|
||||
return err_code;
|
||||
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
|
||||
curproxy->ck_opts = 0;
|
||||
curproxy->cookie_maxidle = curproxy->cookie_maxlife = 0;
|
||||
free(curproxy->cookie_domain); curproxy->cookie_domain = NULL;
|
||||
ha_free(&curproxy->cookie_domain);
|
||||
free(curproxy->cookie_name);
|
||||
curproxy->cookie_name = strdup(args[1]);
|
||||
curproxy->cookie_len = strlen(curproxy->cookie_name);
|
||||
@ -975,8 +975,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
|
||||
free(curproxy->server_state_file_name);
|
||||
curproxy->server_state_file_name = NULL;
|
||||
ha_free(&curproxy->server_state_file_name);
|
||||
|
||||
if (*(args[1]) == 0 || strcmp(args[1], "use-backend-name") == 0)
|
||||
curproxy->server_state_file_name = strdup(curproxy->id);
|
||||
@ -2666,8 +2665,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
|
||||
/* we must first clear any optional default setting */
|
||||
curproxy->conn_src.opts &= ~CO_SRC_TPROXY_MASK;
|
||||
free(curproxy->conn_src.iface_name);
|
||||
curproxy->conn_src.iface_name = NULL;
|
||||
ha_free(&curproxy->conn_src.iface_name);
|
||||
curproxy->conn_src.iface_len = 0;
|
||||
|
||||
sk = str2sa_range(args[1], NULL, &port1, &port2, NULL, NULL,
|
||||
|
@ -106,8 +106,7 @@ static int ssl_load_global_issuers_from_path(char **args, int section_type, stru
|
||||
ssl_load_global_issuer_from_BIO(in, fp, &warn);
|
||||
if (warn) {
|
||||
ha_warning("%s", warn);
|
||||
free(warn);
|
||||
warn = NULL;
|
||||
ha_free(&warn);
|
||||
}
|
||||
next:
|
||||
if (in)
|
||||
@ -1467,8 +1466,7 @@ static int srv_parse_crt(char **args, int *cur_arg, struct proxy *px, struct ser
|
||||
static int srv_parse_no_check_ssl(char **args, int *cur_arg, struct proxy *px, struct server *newsrv, char **err)
|
||||
{
|
||||
newsrv->check.use_ssl = -1;
|
||||
free(newsrv->ssl_ctx.ciphers);
|
||||
newsrv->ssl_ctx.ciphers = NULL;
|
||||
ha_free(&newsrv->ssl_ctx.ciphers);
|
||||
newsrv->ssl_ctx.options &= ~global_ssl.connect_default_ssloptions;
|
||||
return 0;
|
||||
}
|
||||
@ -1497,8 +1495,7 @@ static int srv_parse_no_ssl(char **args, int *cur_arg, struct proxy *px, struct
|
||||
if (newsrv->use_ssl == 1)
|
||||
ssl_sock_init_srv(newsrv);
|
||||
else {
|
||||
free(newsrv->ssl_ctx.ciphers);
|
||||
newsrv->ssl_ctx.ciphers = NULL;
|
||||
ha_free(&newsrv->ssl_ctx.ciphers);
|
||||
}
|
||||
newsrv->use_ssl = -1;
|
||||
return 0;
|
||||
|
@ -1081,14 +1081,10 @@ int cfg_parse_mailers(const char *file, int linenum, char **args, int kwm)
|
||||
|
||||
void free_email_alert(struct proxy *p)
|
||||
{
|
||||
free(p->email_alert.mailers.name);
|
||||
p->email_alert.mailers.name = NULL;
|
||||
free(p->email_alert.from);
|
||||
p->email_alert.from = NULL;
|
||||
free(p->email_alert.to);
|
||||
p->email_alert.to = NULL;
|
||||
free(p->email_alert.myhostname);
|
||||
p->email_alert.myhostname = NULL;
|
||||
ha_free(&p->email_alert.mailers.name);
|
||||
ha_free(&p->email_alert.from);
|
||||
ha_free(&p->email_alert.to);
|
||||
ha_free(&p->email_alert.myhostname);
|
||||
}
|
||||
|
||||
|
||||
@ -1816,8 +1812,7 @@ int readcfgfile(const char *file)
|
||||
err_code |= ERR_ALERT | ERR_FATAL | ERR_ABORT;
|
||||
}
|
||||
err:
|
||||
free(cfg_scope);
|
||||
cfg_scope = NULL;
|
||||
ha_free(&cfg_scope);
|
||||
cursection = NULL;
|
||||
free(thisline);
|
||||
free(outline);
|
||||
@ -1986,8 +1981,7 @@ int check_config_validity()
|
||||
* allocated yet) but let's skip them.
|
||||
*/
|
||||
if (curproxy->table) {
|
||||
free((void *)curproxy->table->peers.name);
|
||||
curproxy->table->peers.name = NULL;
|
||||
ha_free(&curproxy->table->peers.name);
|
||||
curproxy->table->peers.p = NULL;
|
||||
}
|
||||
continue;
|
||||
@ -2209,8 +2203,7 @@ int check_config_validity()
|
||||
cfgerr++;
|
||||
}
|
||||
if (clear) {
|
||||
free(curproxy->check_command);
|
||||
curproxy->check_command = NULL;
|
||||
ha_free(&curproxy->check_command);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2219,8 +2212,7 @@ int check_config_validity()
|
||||
ha_warning("config : '%s' will be ignored for %s '%s' (requires 'option external-check').\n",
|
||||
"external-check path", proxy_type_str(curproxy), curproxy->id);
|
||||
err_code |= ERR_WARN;
|
||||
free(curproxy->check_path);
|
||||
curproxy->check_path = NULL;
|
||||
ha_free(&curproxy->check_path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2606,8 +2598,7 @@ int check_config_validity()
|
||||
LIST_ADDQ(&curproxy->uri_auth->http_req_rules, &rule->list);
|
||||
|
||||
if (curproxy->uri_auth->auth_realm) {
|
||||
free(curproxy->uri_auth->auth_realm);
|
||||
curproxy->uri_auth->auth_realm = NULL;
|
||||
ha_free(&curproxy->uri_auth->auth_realm);
|
||||
}
|
||||
curproxy->uri_auth->flags |= STAT_CONVDONE;
|
||||
}
|
||||
@ -2631,15 +2622,13 @@ int check_config_validity()
|
||||
curproxy->conf.logformat_string != clf_http_log_format)
|
||||
free(curproxy->conf.logformat_string);
|
||||
curproxy->conf.logformat_string = NULL;
|
||||
free(curproxy->conf.lfs_file);
|
||||
curproxy->conf.lfs_file = NULL;
|
||||
ha_free(&curproxy->conf.lfs_file);
|
||||
curproxy->conf.lfs_line = 0;
|
||||
|
||||
if (curproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format)
|
||||
free(curproxy->conf.logformat_sd_string);
|
||||
curproxy->conf.logformat_sd_string = NULL;
|
||||
free(curproxy->conf.lfsd_file);
|
||||
curproxy->conf.lfsd_file = NULL;
|
||||
ha_free(&curproxy->conf.lfsd_file);
|
||||
curproxy->conf.lfsd_line = 0;
|
||||
}
|
||||
|
||||
@ -2937,8 +2926,7 @@ int check_config_validity()
|
||||
newsrv->tracknext = srv->trackers;
|
||||
srv->trackers = newsrv;
|
||||
|
||||
free(newsrv->trackit);
|
||||
newsrv->trackit = NULL;
|
||||
ha_free(&newsrv->trackit);
|
||||
}
|
||||
|
||||
next_srv:
|
||||
|
@ -1062,8 +1062,7 @@ void free_check(struct check *check)
|
||||
check_release_buf(check, &check->bi);
|
||||
check_release_buf(check, &check->bo);
|
||||
if (check->cs) {
|
||||
free(check->cs->conn);
|
||||
check->cs->conn = NULL;
|
||||
ha_free(&check->cs->conn);
|
||||
cs_free(check->cs);
|
||||
check->cs = NULL;
|
||||
}
|
||||
@ -1478,8 +1477,7 @@ static void deinit_srv_agent_check(struct server *srv)
|
||||
{
|
||||
if (srv->agent.tcpcheck_rules) {
|
||||
free_tcpcheck_vars(&srv->agent.tcpcheck_rules->preset_vars);
|
||||
free(srv->agent.tcpcheck_rules);
|
||||
srv->agent.tcpcheck_rules = NULL;
|
||||
ha_free(&srv->agent.tcpcheck_rules);
|
||||
}
|
||||
|
||||
if (srv->agent.state & CHK_ST_CONFIGURED)
|
||||
|
21
src/cli.c
21
src/cli.c
@ -98,8 +98,7 @@ static char *cli_gen_usage_msg(struct appctx *appctx)
|
||||
struct buffer *tmp = get_trash_chunk();
|
||||
struct buffer out;
|
||||
|
||||
free(dynamic_usage_msg);
|
||||
dynamic_usage_msg = NULL;
|
||||
ha_free(&dynamic_usage_msg);
|
||||
|
||||
if (LIST_ISEMPTY(&cli_keywords.list))
|
||||
goto end;
|
||||
@ -851,8 +850,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
if (cli_output_msg(res, msg, sev, cli_get_severity_output(appctx)) != -1) {
|
||||
if (appctx->st0 == CLI_ST_PRINT_FREE ||
|
||||
appctx->st0 == CLI_ST_PRINT_DYN) {
|
||||
free(appctx->ctx.cli.err);
|
||||
appctx->ctx.cli.err = NULL;
|
||||
ha_free(&appctx->ctx.cli.err);
|
||||
}
|
||||
appctx->st0 = CLI_ST_PROMPT;
|
||||
}
|
||||
@ -961,8 +959,7 @@ static void cli_release_handler(struct appctx *appctx)
|
||||
appctx->io_release = NULL;
|
||||
}
|
||||
else if (appctx->st0 == CLI_ST_PRINT_FREE || appctx->st0 == CLI_ST_PRINT_DYN) {
|
||||
free(appctx->ctx.cli.err);
|
||||
appctx->ctx.cli.err = NULL;
|
||||
ha_free(&appctx->ctx.cli.err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2580,8 +2577,7 @@ int mworker_cli_proxy_create()
|
||||
&errmsg, NULL, NULL, PA_O_STREAM)) == 0) {
|
||||
goto error;
|
||||
}
|
||||
free(msg);
|
||||
msg = NULL;
|
||||
ha_free(&msg);
|
||||
|
||||
if (!proto->connect) {
|
||||
goto error;
|
||||
@ -2605,13 +2601,11 @@ int mworker_cli_proxy_create()
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
free((char *)child->srv->conf.file); /* cast because of const char * */
|
||||
free(child->srv->id);
|
||||
free(child->srv);
|
||||
child->srv = NULL;
|
||||
ha_free(&child->srv);
|
||||
}
|
||||
free(mworker_proxy->id);
|
||||
free(mworker_proxy->conf.file);
|
||||
free(mworker_proxy);
|
||||
mworker_proxy = NULL;
|
||||
ha_free(&mworker_proxy);
|
||||
free(errmsg);
|
||||
free(msg);
|
||||
|
||||
@ -2765,8 +2759,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
|
||||
ha_alert("Cannot create a CLI sockpair listener for process #%d\n", proc);
|
||||
goto error;
|
||||
}
|
||||
free(path);
|
||||
path = NULL;
|
||||
ha_free(&path);
|
||||
|
||||
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
|
||||
l->accept = session_accept_fd;
|
||||
|
@ -42,8 +42,7 @@ static struct dict_entry *new_dict_entry(char *s)
|
||||
return de;
|
||||
|
||||
err:
|
||||
free(de->value.key);
|
||||
de->value.key = NULL;
|
||||
ha_free(&de->value.key);
|
||||
de->len = 0;
|
||||
free(de);
|
||||
return NULL;
|
||||
@ -55,8 +54,7 @@ static struct dict_entry *new_dict_entry(char *s)
|
||||
static void free_dict_entry(struct dict_entry *de)
|
||||
{
|
||||
de->refcount = 0;
|
||||
free(de->value.key);
|
||||
de->value.key = NULL;
|
||||
ha_free(&de->value.key);
|
||||
free(de);
|
||||
}
|
||||
|
||||
|
@ -1304,8 +1304,7 @@ int init_dns_buffers()
|
||||
|
||||
void deinit_dns_buffers()
|
||||
{
|
||||
free(dns_msg_trash);
|
||||
dns_msg_trash = NULL;
|
||||
ha_free(&dns_msg_trash);
|
||||
}
|
||||
|
||||
REGISTER_PER_THREAD_ALLOC(init_dns_buffers);
|
||||
|
@ -287,8 +287,7 @@ static void deinit_epoll_per_thread()
|
||||
if (MAX_THREADS > 1 && tid)
|
||||
close(epoll_fd[tid]);
|
||||
|
||||
free(epoll_events);
|
||||
epoll_events = NULL;
|
||||
ha_free(&epoll_events);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -309,8 +309,7 @@ static int init_evports_per_thread()
|
||||
return 1;
|
||||
|
||||
fail_fd:
|
||||
free(evports_evlist);
|
||||
evports_evlist = NULL;
|
||||
ha_free(&evports_evlist);
|
||||
evports_evlist_max = 0;
|
||||
fail_alloc:
|
||||
return 0;
|
||||
@ -321,8 +320,7 @@ static void deinit_evports_per_thread()
|
||||
if (MAX_THREADS > 1 && tid)
|
||||
close(evports_fd[tid]);
|
||||
|
||||
free(evports_evlist);
|
||||
evports_evlist = NULL;
|
||||
ha_free(&evports_evlist);
|
||||
evports_evlist_max = 0;
|
||||
}
|
||||
|
||||
@ -362,8 +360,7 @@ static void _do_term(struct poller *p)
|
||||
p->private = NULL;
|
||||
p->pref = 0;
|
||||
|
||||
free(evports_evlist);
|
||||
evports_evlist = NULL;
|
||||
ha_free(&evports_evlist);
|
||||
evports_evlist_max = 0;
|
||||
}
|
||||
|
||||
|
@ -252,8 +252,7 @@ static void deinit_kqueue_per_thread()
|
||||
if (MAX_THREADS > 1 && tid)
|
||||
close(kqueue_fd[tid]);
|
||||
|
||||
free(kev);
|
||||
kev = NULL;
|
||||
ha_free(&kev);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -283,8 +282,7 @@ static int _do_init(struct poller *p)
|
||||
return 1;
|
||||
|
||||
fail_fd:
|
||||
free(kev_out);
|
||||
kev_out = NULL;
|
||||
ha_free(&kev_out);
|
||||
fail_alloc:
|
||||
p->pref = 0;
|
||||
return 0;
|
||||
@ -304,8 +302,7 @@ static void _do_term(struct poller *p)
|
||||
p->private = NULL;
|
||||
p->pref = 0;
|
||||
if (kev_out) {
|
||||
free(kev_out);
|
||||
kev_out = NULL;
|
||||
ha_free(&kev_out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,8 +258,7 @@ static int init_poll_per_thread()
|
||||
|
||||
static void deinit_poll_per_thread()
|
||||
{
|
||||
free(poll_events);
|
||||
poll_events = NULL;
|
||||
ha_free(&poll_events);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -241,10 +241,8 @@ static int init_select_per_thread()
|
||||
|
||||
static void deinit_select_per_thread()
|
||||
{
|
||||
free(tmp_evts[DIR_WR]);
|
||||
tmp_evts[DIR_WR] = NULL;
|
||||
free(tmp_evts[DIR_RD]);
|
||||
tmp_evts[DIR_RD] = NULL;
|
||||
ha_free(&tmp_evts[DIR_WR]);
|
||||
ha_free(&tmp_evts[DIR_RD]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -358,15 +358,13 @@ int prepare_external_check(struct check *check)
|
||||
if (check->envp) {
|
||||
for (i = 0; i < EXTCHK_SIZE; i++)
|
||||
free(check->envp[i]);
|
||||
free(check->envp);
|
||||
check->envp = NULL;
|
||||
ha_free(&check->envp);
|
||||
}
|
||||
|
||||
if (check->argv) {
|
||||
for (i = 1; i < 5; i++)
|
||||
free(check->argv[i]);
|
||||
free(check->argv);
|
||||
check->argv = NULL;
|
||||
ha_free(&check->argv);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -552,8 +552,7 @@ parse_fcgi_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
/* Place the filter at its right position */
|
||||
LIST_DEL(&f->list);
|
||||
free(f);
|
||||
free(name);
|
||||
name = NULL;
|
||||
ha_free(&name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
9
src/fd.c
9
src/fd.c
@ -649,8 +649,7 @@ static void deinit_pollers_per_thread()
|
||||
/* Release the pollers per thread, to be called late */
|
||||
static void free_pollers_per_thread()
|
||||
{
|
||||
free(fd_updt);
|
||||
fd_updt = NULL;
|
||||
ha_free(&fd_updt);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -723,9 +722,9 @@ void deinit_pollers() {
|
||||
bp->term(bp);
|
||||
}
|
||||
|
||||
free(fdinfo); fdinfo = NULL;
|
||||
free(fdtab); fdtab = NULL;
|
||||
free(polled_mask); polled_mask = NULL;
|
||||
ha_free(&fdinfo);
|
||||
ha_free(&fdtab);
|
||||
ha_free(&polled_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3099,8 +3099,7 @@ spoe_check(struct proxy *px, struct flt_conf *fconf)
|
||||
}
|
||||
}
|
||||
|
||||
free(conf->agent->b.name);
|
||||
conf->agent->b.name = NULL;
|
||||
ha_free(&conf->agent->b.name);
|
||||
conf->agent->b.be = target;
|
||||
return 0;
|
||||
}
|
||||
|
@ -841,13 +841,11 @@ void mworker_reload()
|
||||
execvp(next_argv[0], next_argv);
|
||||
|
||||
ha_warning("Failed to reexecute the master process [%d]: %s\n", pid, strerror(errno));
|
||||
free(next_argv);
|
||||
next_argv = NULL;
|
||||
ha_free(&next_argv);
|
||||
return;
|
||||
|
||||
alloc_error:
|
||||
free(next_argv);
|
||||
next_argv = NULL;
|
||||
ha_free(&next_argv);
|
||||
ha_warning("Failed to reexecute the master process [%d]: Cannot allocate memory\n", pid);
|
||||
return;
|
||||
}
|
||||
@ -2758,17 +2756,17 @@ void deinit(void)
|
||||
list_for_each_entry(pdf, &post_deinit_list, list)
|
||||
pdf->fct();
|
||||
|
||||
free(global.log_send_hostname); global.log_send_hostname = NULL;
|
||||
ha_free(&global.log_send_hostname);
|
||||
chunk_destroy(&global.log_tag);
|
||||
free(global.chroot); global.chroot = NULL;
|
||||
free(global.pidfile); global.pidfile = NULL;
|
||||
free(global.node); global.node = NULL;
|
||||
free(global.desc); global.desc = NULL;
|
||||
free(oldpids); oldpids = NULL;
|
||||
free(old_argv); old_argv = NULL;
|
||||
free(localpeer); localpeer = NULL;
|
||||
free(global.server_state_base); global.server_state_base = NULL;
|
||||
free(global.server_state_file); global.server_state_file = NULL;
|
||||
ha_free(&global.chroot);
|
||||
ha_free(&global.pidfile);
|
||||
ha_free(&global.node);
|
||||
ha_free(&global.desc);
|
||||
ha_free(&oldpids);
|
||||
ha_free(&old_argv);
|
||||
ha_free(&localpeer);
|
||||
ha_free(&global.server_state_base);
|
||||
ha_free(&global.server_state_file);
|
||||
task_destroy(idle_conn_task);
|
||||
idle_conn_task = NULL;
|
||||
|
||||
@ -3314,8 +3312,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) {
|
||||
nb_oldpids = 0;
|
||||
free(oldpids);
|
||||
oldpids = NULL;
|
||||
ha_free(&oldpids);
|
||||
}
|
||||
|
||||
|
||||
@ -3452,7 +3449,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* We won't ever use this anymore */
|
||||
free(global.pidfile); global.pidfile = NULL;
|
||||
ha_free(&global.pidfile);
|
||||
|
||||
if (proc == global.nbproc) {
|
||||
if (global.mode & (MODE_MWORKER|MODE_MWORKER_WAIT)) {
|
||||
@ -3527,8 +3524,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
free(global.chroot);
|
||||
global.chroot = NULL;
|
||||
ha_free(&global.chroot);
|
||||
set_identity(argv[0]);
|
||||
|
||||
/* pass through every cli socket, and check if it's bound to
|
||||
|
@ -68,8 +68,7 @@ static int alloc_raw_htx_chunk_per_thread()
|
||||
|
||||
static void free_raw_htx_chunk_per_thread()
|
||||
{
|
||||
free(static_raw_htx_buf);
|
||||
static_raw_htx_buf = NULL;
|
||||
ha_free(&static_raw_htx_buf);
|
||||
}
|
||||
|
||||
REGISTER_PER_THREAD_ALLOC(alloc_raw_htx_chunk_per_thread);
|
||||
|
@ -1009,8 +1009,7 @@ void release_http_reply(struct http_reply *http_reply)
|
||||
if (!http_reply)
|
||||
return;
|
||||
|
||||
free(http_reply->ctype);
|
||||
http_reply->ctype = NULL;
|
||||
ha_free(&http_reply->ctype);
|
||||
list_for_each_entry_safe(hdr, hdrb, &http_reply->hdrs, list) {
|
||||
LIST_DEL(&hdr->list);
|
||||
list_for_each_entry_safe(lf, lfb, &hdr->value, list) {
|
||||
@ -1024,8 +1023,7 @@ void release_http_reply(struct http_reply *http_reply)
|
||||
}
|
||||
|
||||
if (http_reply->type == HTTP_REPLY_ERRFILES) {
|
||||
free(http_reply->body.http_errors);
|
||||
http_reply->body.http_errors = NULL;
|
||||
ha_free(&http_reply->body.http_errors);
|
||||
}
|
||||
else if (http_reply->type == HTTP_REPLY_RAW)
|
||||
chunk_destroy(&http_reply->body.obj);
|
||||
@ -1067,8 +1065,7 @@ static int http_htx_init(void)
|
||||
}
|
||||
|
||||
/* Reset errmsg */
|
||||
free(errmsg);
|
||||
errmsg = NULL;
|
||||
ha_free(&errmsg);
|
||||
|
||||
http_err_chunks[rc] = chk;
|
||||
http_err_replies[rc].type = HTTP_REPLY_ERRMSG;
|
||||
@ -1627,8 +1624,7 @@ struct http_reply *http_parse_http_reply(const char **args, int *orig_arg, struc
|
||||
ha_warning("parsing [%s:%d] : content-type '%s' ignored by the http reply because"
|
||||
" neither errorfile nor payload defined.\n",
|
||||
px->conf.args.file, px->conf.args.line, reply->ctype);
|
||||
free(reply->ctype);
|
||||
reply->ctype = NULL;
|
||||
ha_free(&reply->ctype);
|
||||
}
|
||||
}
|
||||
else if (reply->type == HTTP_REPLY_ERRFILES || reply->type == HTTP_REPLY_ERRMSG) { /* errorfiles or errorfile */
|
||||
@ -1653,8 +1649,7 @@ struct http_reply *http_parse_http_reply(const char **args, int *orig_arg, struc
|
||||
ha_warning("parsing [%s:%d] : content-type '%s' ignored by the http reply when used "
|
||||
"with an erorrfile.\n",
|
||||
px->conf.args.file, px->conf.args.line, reply->ctype);
|
||||
free(reply->ctype);
|
||||
reply->ctype = NULL;
|
||||
ha_free(&reply->ctype);
|
||||
}
|
||||
if (!LIST_ISEMPTY(&reply->hdrs)) {
|
||||
ha_warning("parsing [%s:%d] : hdr parameters ignored by the http reply when used "
|
||||
@ -1686,8 +1681,7 @@ struct http_reply *http_parse_http_reply(const char **args, int *orig_arg, struc
|
||||
ha_warning("parsing [%s:%d] : content-type '%s' ignored by the http reply when used "
|
||||
"with an empty payload.\n",
|
||||
px->conf.args.file, px->conf.args.line, reply->ctype);
|
||||
free(reply->ctype);
|
||||
reply->ctype = NULL;
|
||||
ha_free(&reply->ctype);
|
||||
}
|
||||
if (b_room(&reply->body.obj) < global.tune.maxrewrite) {
|
||||
ha_warning("parsing [%s:%d] : http reply payload runs over the buffer space reserved to headers rewriting."
|
||||
|
@ -50,8 +50,7 @@ void email_alert_free(struct email_alert *alert)
|
||||
free_tcpcheck(rule, 1);
|
||||
}
|
||||
free_tcpcheck_vars(&alert->rules.preset_vars);
|
||||
free(alert->rules.list);
|
||||
alert->rules.list = NULL;
|
||||
ha_free(&alert->rules.list);
|
||||
}
|
||||
pool_free(pool_head_email_alert, alert);
|
||||
}
|
||||
|
@ -585,8 +585,7 @@ static int cli_io_handler_map_lookup(struct appctx *appctx)
|
||||
|
||||
static void cli_release_mlook(struct appctx *appctx)
|
||||
{
|
||||
free(appctx->ctx.map.chunk.area);
|
||||
appctx->ctx.map.chunk.area = NULL;
|
||||
ha_free(&appctx->ctx.map.chunk.area);
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,18 +307,14 @@ int cfg_parse_program(const char *file, int linenum, char **args, int kwm)
|
||||
int i;
|
||||
|
||||
for (i = 0; ext_child->command[i]; i++) {
|
||||
free(ext_child->command[i]);
|
||||
ext_child->command[i] = NULL;
|
||||
ha_free(&ext_child->command[i]);
|
||||
}
|
||||
free(ext_child->command);
|
||||
ext_child->command = NULL;
|
||||
ha_free(&ext_child->command);
|
||||
}
|
||||
free(ext_child->id);
|
||||
ext_child->id = NULL;
|
||||
ha_free(&ext_child->id);
|
||||
}
|
||||
|
||||
free(ext_child);
|
||||
ext_child = NULL;
|
||||
ha_free(&ext_child);
|
||||
|
||||
out:
|
||||
return err_code;
|
||||
|
@ -458,8 +458,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s %-15s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>", "<version>");
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", (unsigned int)getpid(), "master", 0, proc_self->reloads, uptime, haproxy_version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
ha_free(&uptime);
|
||||
|
||||
/* displays current processes */
|
||||
|
||||
@ -476,8 +475,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
}
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", child->pid, "worker", child->relative_pid, child->reloads, uptime, child->version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
ha_free(&uptime);
|
||||
}
|
||||
|
||||
/* displays old processes */
|
||||
@ -496,8 +494,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
memprintf(&msg, "[was: %u]", child->relative_pid);
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, "worker", msg, child->reloads, uptime, child->version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
ha_free(&uptime);
|
||||
}
|
||||
}
|
||||
free(msg);
|
||||
@ -518,8 +515,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
}
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, child->id, "-", child->reloads, uptime, "-");
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
ha_free(&uptime);
|
||||
}
|
||||
|
||||
if (old) {
|
||||
@ -533,8 +529,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, child->id, "-", child->reloads, uptime, "-");
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
ha_free(&uptime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -598,21 +593,17 @@ void mworker_free_child(struct mworker_proc *child)
|
||||
|
||||
for (i = 0; child->command[i]; i++) {
|
||||
if (child->command[i]) {
|
||||
free(child->command[i]);
|
||||
child->command[i] = NULL;
|
||||
ha_free(&child->command[i]);
|
||||
}
|
||||
|
||||
}
|
||||
free(child->command);
|
||||
child->command = NULL;
|
||||
ha_free(&child->command);
|
||||
}
|
||||
if (child->id) {
|
||||
free(child->id);
|
||||
child->id = NULL;
|
||||
ha_free(&child->id);
|
||||
}
|
||||
if (child->version) {
|
||||
free(child->version);
|
||||
child->version = NULL;
|
||||
ha_free(&child->version);
|
||||
}
|
||||
free(child);
|
||||
}
|
||||
|
@ -1772,8 +1772,7 @@ int pat_ref_set(struct pat_ref *ref, const char *key, const char *value, char **
|
||||
*err = *merr;
|
||||
} else {
|
||||
memprintf(err, "%s, %s", *err, *merr);
|
||||
free(*merr);
|
||||
*merr = NULL;
|
||||
ha_free(merr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int protocol_bind_all(int verbose)
|
||||
else if (lerr & ERR_WARN)
|
||||
ha_warning("Starting %s %s: %s\n",
|
||||
proxy_type_str(px), px->id, errmsg);
|
||||
free(errmsg); errmsg = NULL;
|
||||
ha_free(&errmsg);
|
||||
}
|
||||
if (lerr & ERR_ABORT)
|
||||
break;
|
||||
|
57
src/proxy.c
57
src/proxy.c
@ -1119,40 +1119,37 @@ void proxy_preset_defaults(struct proxy *defproxy)
|
||||
*/
|
||||
void proxy_free_defaults(struct proxy *defproxy)
|
||||
{
|
||||
free(defproxy->id); defproxy->id = NULL;
|
||||
free(defproxy->conf.file); defproxy->conf.file = NULL;
|
||||
free(defproxy->check_command); defproxy->check_command = NULL;
|
||||
free(defproxy->check_path); defproxy->check_path = NULL;
|
||||
free(defproxy->cookie_name); defproxy->cookie_name = NULL;
|
||||
free(defproxy->rdp_cookie_name); defproxy->rdp_cookie_name = NULL;
|
||||
free(defproxy->dyncookie_key); defproxy->dyncookie_key = NULL;
|
||||
free(defproxy->cookie_domain); defproxy->cookie_domain = NULL;
|
||||
free(defproxy->cookie_attrs); defproxy->cookie_attrs = NULL;
|
||||
free(defproxy->lbprm.arg_str); defproxy->lbprm.arg_str = NULL;
|
||||
free(defproxy->capture_name); defproxy->capture_name = NULL;
|
||||
free(defproxy->monitor_uri); defproxy->monitor_uri = NULL;
|
||||
free(defproxy->defbe.name); defproxy->defbe.name = NULL;
|
||||
free(defproxy->conn_src.iface_name); defproxy->conn_src.iface_name = NULL;
|
||||
free(defproxy->fwdfor_hdr_name); defproxy->fwdfor_hdr_name = NULL; defproxy->fwdfor_hdr_len = 0;
|
||||
free(defproxy->orgto_hdr_name); defproxy->orgto_hdr_name = NULL; defproxy->orgto_hdr_len = 0;
|
||||
free(defproxy->server_id_hdr_name); defproxy->server_id_hdr_name = NULL; defproxy->server_id_hdr_len = 0;
|
||||
ha_free(&defproxy->id);
|
||||
ha_free(&defproxy->conf.file);
|
||||
ha_free(&defproxy->check_command);
|
||||
ha_free(&defproxy->check_path);
|
||||
ha_free(&defproxy->cookie_name);
|
||||
ha_free(&defproxy->rdp_cookie_name);
|
||||
ha_free(&defproxy->dyncookie_key);
|
||||
ha_free(&defproxy->cookie_domain);
|
||||
ha_free(&defproxy->cookie_attrs);
|
||||
ha_free(&defproxy->lbprm.arg_str);
|
||||
ha_free(&defproxy->capture_name);
|
||||
ha_free(&defproxy->monitor_uri);
|
||||
ha_free(&defproxy->defbe.name);
|
||||
ha_free(&defproxy->conn_src.iface_name);
|
||||
ha_free(&defproxy->fwdfor_hdr_name); defproxy->fwdfor_hdr_len = 0;
|
||||
ha_free(&defproxy->orgto_hdr_name); defproxy->orgto_hdr_len = 0;
|
||||
ha_free(&defproxy->server_id_hdr_name); defproxy->server_id_hdr_len = 0;
|
||||
|
||||
if (defproxy->conf.logformat_string != default_http_log_format &&
|
||||
defproxy->conf.logformat_string != default_tcp_log_format &&
|
||||
defproxy->conf.logformat_string != clf_http_log_format) {
|
||||
free(defproxy->conf.logformat_string);
|
||||
defproxy->conf.logformat_string = NULL;
|
||||
ha_free(&defproxy->conf.logformat_string);
|
||||
}
|
||||
|
||||
if (defproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format) {
|
||||
free(defproxy->conf.logformat_sd_string);
|
||||
defproxy->conf.logformat_sd_string = NULL;
|
||||
}
|
||||
if (defproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format)
|
||||
ha_free(&defproxy->conf.logformat_sd_string);
|
||||
|
||||
free(defproxy->conf.uniqueid_format_string); defproxy->conf.uniqueid_format_string = NULL;
|
||||
free(defproxy->conf.lfs_file); defproxy->conf.lfs_file = NULL;
|
||||
free(defproxy->conf.lfsd_file); defproxy->conf.lfsd_file = NULL;
|
||||
free(defproxy->conf.uif_file); defproxy->conf.uif_file = NULL;
|
||||
ha_free(&defproxy->conf.uniqueid_format_string);
|
||||
ha_free(&defproxy->conf.lfs_file);
|
||||
ha_free(&defproxy->conf.lfsd_file);
|
||||
ha_free(&defproxy->conf.uif_file);
|
||||
chunk_destroy(&defproxy->log_tag);
|
||||
|
||||
free_email_alert(defproxy);
|
||||
@ -2415,10 +2412,8 @@ static int cli_parse_disable_dyncookie_backend(char **args, char *payload, struc
|
||||
|
||||
for (s = px->srv; s != NULL; s = s->next) {
|
||||
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
|
||||
if (!(s->flags & SRV_F_COOKIESET)) {
|
||||
free(s->cookie);
|
||||
s->cookie = NULL;
|
||||
}
|
||||
if (!(s->flags & SRV_F_COOKIESET))
|
||||
ha_free(&s->cookie);
|
||||
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
||||
}
|
||||
|
||||
|
@ -572,10 +572,8 @@ static void resolv_check_response(struct resolv_resolution *res)
|
||||
item->data_len == srv->hostname_dn_len &&
|
||||
!resolv_hostname_cmp(srv->hostname_dn, item->target, item->data_len)) {
|
||||
snr_update_srv_status(srv, 1);
|
||||
free(srv->hostname);
|
||||
free(srv->hostname_dn);
|
||||
srv->hostname = NULL;
|
||||
srv->hostname_dn = NULL;
|
||||
ha_free(&srv->hostname);
|
||||
ha_free(&srv->hostname_dn);
|
||||
srv->hostname_dn_len = 0;
|
||||
memset(&srv->addr, 0, sizeof(srv->addr));
|
||||
srv->svc_port = 0;
|
||||
@ -2509,7 +2507,7 @@ static int action_prepare_for_resolution(struct stream *stream, const char *host
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free(stream->resolv_ctx.hostname_dn); stream->resolv_ctx.hostname_dn = NULL;
|
||||
ha_free(&stream->resolv_ctx.hostname_dn);
|
||||
resolv_failed_resolutions += 1;
|
||||
return -1;
|
||||
}
|
||||
@ -2620,8 +2618,7 @@ enum act_return resolv_action_do_resolve(struct act_rule *rule, struct proxy *px
|
||||
return ret;
|
||||
|
||||
release_requester:
|
||||
free(s->resolv_ctx.hostname_dn);
|
||||
s->resolv_ctx.hostname_dn = NULL;
|
||||
ha_free(&s->resolv_ctx.hostname_dn);
|
||||
s->resolv_ctx.hostname_dn_len = 0;
|
||||
if (s->resolv_ctx.requester) {
|
||||
resolv_unlink_resolution(s->resolv_ctx.requester);
|
||||
@ -2750,8 +2747,8 @@ enum act_parse_ret resolv_parse_do_resolve(const char **args, int *orig_arg, str
|
||||
return ACT_RET_PRS_OK;
|
||||
|
||||
do_resolve_parse_error:
|
||||
free(rule->arg.resolv.varname); rule->arg.resolv.varname = NULL;
|
||||
free(rule->arg.resolv.resolvers_id); rule->arg.resolv.resolvers_id = NULL;
|
||||
ha_free(&rule->arg.resolv.varname);
|
||||
ha_free(&rule->arg.resolv.resolvers_id);
|
||||
memprintf(err, "Can't parse '%s'. Expects 'do-resolve(<varname>,<resolvers>[,<options>]) <expr>'. Available options are 'ipv4' and 'ipv6'",
|
||||
args[cur_arg]);
|
||||
return ACT_RET_PRS_ERR;
|
||||
|
@ -1606,8 +1606,8 @@ int srv_prepare_for_resolution(struct server *srv, const char *hostname)
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free(srv->hostname); srv->hostname = NULL;
|
||||
free(srv->hostname_dn); srv->hostname_dn = NULL;
|
||||
ha_free(&srv->hostname);
|
||||
ha_free(&srv->hostname_dn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ static struct sink *__sink_new(const char *name, const char *desc, int fmt)
|
||||
return sink;
|
||||
|
||||
err:
|
||||
free(sink->name); sink->name = NULL;
|
||||
free(sink->desc); sink->desc = NULL;
|
||||
free(sink); sink = NULL;
|
||||
ha_free(&sink->name);
|
||||
ha_free(&sink->desc);
|
||||
ha_free(&sink);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -410,8 +410,7 @@ int sock_get_old_sockets(const char *unixsocket)
|
||||
socklen = sizeof(xfer_sock->addr);
|
||||
if (getsockname(fd, (struct sockaddr *)&xfer_sock->addr, &socklen) != 0) {
|
||||
ha_warning("Failed to get socket address\n");
|
||||
free(xfer_sock);
|
||||
xfer_sock = NULL;
|
||||
ha_free(&xfer_sock);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -130,14 +130,12 @@ int ssl_sock_load_sctl_from_file(const char *sctl_path, char *buf, struct cert_k
|
||||
|
||||
sctl = calloc(1, sizeof(*sctl));
|
||||
if (!chunk_dup(sctl, src)) {
|
||||
free(sctl);
|
||||
sctl = NULL;
|
||||
ha_free(&sctl);
|
||||
goto end;
|
||||
}
|
||||
/* no error, fill ckch with new context, old context must be free */
|
||||
if (ckch->sctl) {
|
||||
free(ckch->sctl->area);
|
||||
ckch->sctl->area = NULL;
|
||||
ha_free(&ckch->sctl->area);
|
||||
free(ckch->sctl);
|
||||
}
|
||||
ckch->sctl = sctl;
|
||||
@ -212,14 +210,12 @@ int ssl_sock_load_ocsp_response_from_file(const char *ocsp_path, char *buf, stru
|
||||
|
||||
ocsp_response = calloc(1, sizeof(*ocsp_response));
|
||||
if (!chunk_dup(ocsp_response, src)) {
|
||||
free(ocsp_response);
|
||||
ocsp_response = NULL;
|
||||
ha_free(&ocsp_response);
|
||||
goto end;
|
||||
}
|
||||
/* no error, fill ckch with new context, old context must be free */
|
||||
if (ckch->ocsp_response) {
|
||||
free(ckch->ocsp_response->area);
|
||||
ckch->ocsp_response->area = NULL;
|
||||
ha_free(&ckch->ocsp_response->area);
|
||||
free(ckch->ocsp_response);
|
||||
}
|
||||
ckch->ocsp_response = ocsp_response;
|
||||
@ -562,17 +558,13 @@ int ssl_sock_load_pem_into_ckch(const char *path, char *buf, struct cert_key_and
|
||||
|
||||
/* once it loaded the PEM, it should remove everything else in the ckch */
|
||||
if (ckch->ocsp_response) {
|
||||
free(ckch->ocsp_response->area);
|
||||
ckch->ocsp_response->area = NULL;
|
||||
free(ckch->ocsp_response);
|
||||
ckch->ocsp_response = NULL;
|
||||
ha_free(&ckch->ocsp_response->area);
|
||||
ha_free(&ckch->ocsp_response);
|
||||
}
|
||||
|
||||
if (ckch->sctl) {
|
||||
free(ckch->sctl->area);
|
||||
ckch->sctl->area = NULL;
|
||||
free(ckch->sctl);
|
||||
ckch->sctl = NULL;
|
||||
ha_free(&ckch->sctl->area);
|
||||
ha_free(&ckch->sctl);
|
||||
}
|
||||
|
||||
if (ckch->ocsp_issuer) {
|
||||
@ -632,17 +624,13 @@ void ssl_sock_free_cert_key_and_chain_contents(struct cert_key_and_chain *ckch)
|
||||
ckch->dh = NULL;
|
||||
|
||||
if (ckch->sctl) {
|
||||
free(ckch->sctl->area);
|
||||
ckch->sctl->area = NULL;
|
||||
free(ckch->sctl);
|
||||
ckch->sctl = NULL;
|
||||
ha_free(&ckch->sctl->area);
|
||||
ha_free(&ckch->sctl);
|
||||
}
|
||||
|
||||
if (ckch->ocsp_response) {
|
||||
free(ckch->ocsp_response->area);
|
||||
ckch->ocsp_response->area = NULL;
|
||||
free(ckch->ocsp_response);
|
||||
ckch->ocsp_response = NULL;
|
||||
ha_free(&ckch->ocsp_response->area);
|
||||
ha_free(&ckch->ocsp_response);
|
||||
}
|
||||
|
||||
if (ckch->ocsp_issuer)
|
||||
@ -689,8 +677,7 @@ struct cert_key_and_chain *ssl_sock_copy_cert_key_and_chain(struct cert_key_and_
|
||||
|
||||
sctl = calloc(1, sizeof(*sctl));
|
||||
if (!chunk_dup(sctl, src->sctl)) {
|
||||
free(sctl);
|
||||
sctl = NULL;
|
||||
ha_free(&sctl);
|
||||
goto error;
|
||||
}
|
||||
dst->sctl = sctl;
|
||||
@ -701,8 +688,7 @@ struct cert_key_and_chain *ssl_sock_copy_cert_key_and_chain(struct cert_key_and_
|
||||
|
||||
ocsp_response = calloc(1, sizeof(*ocsp_response));
|
||||
if (!chunk_dup(ocsp_response, src->ocsp_response)) {
|
||||
free(ocsp_response);
|
||||
ocsp_response = NULL;
|
||||
ha_free(&ocsp_response);
|
||||
goto error;
|
||||
}
|
||||
dst->ocsp_response = ocsp_response;
|
||||
@ -788,8 +774,7 @@ void ckch_store_free(struct ckch_store *store)
|
||||
|
||||
ssl_sock_free_cert_key_and_chain_contents(store->ckch);
|
||||
|
||||
free(store->ckch);
|
||||
store->ckch = NULL;
|
||||
ha_free(&store->ckch);
|
||||
|
||||
list_for_each_entry_safe(inst, inst_s, &store->ckch_inst, by_ckchs) {
|
||||
ckch_inst_free(inst);
|
||||
@ -1418,10 +1403,9 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
|
||||
ckchi->server->ssl_ctx.inst = ckchi;
|
||||
|
||||
/* flush the session cache of the server */
|
||||
for (i = 0; i < global.nbthread; i++) {
|
||||
free(ckchi->server->ssl_ctx.reused_sess[i].ptr);
|
||||
ckchi->server->ssl_ctx.reused_sess[i].ptr = NULL;
|
||||
}
|
||||
for (i = 0; i < global.nbthread; i++)
|
||||
ha_free(&ckchi->server->ssl_ctx.reused_sess[i].ptr);
|
||||
|
||||
HA_RWLOCK_WRUNLOCK(SSL_SERVER_LOCK, &ckchi->server->ssl_ctx.lock);
|
||||
|
||||
} else {
|
||||
@ -1453,8 +1437,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
|
||||
/* fallthrough */
|
||||
case SETCERT_ST_FIN:
|
||||
/* we achieved the transaction, we can set everything to NULL */
|
||||
free(ckchs_transaction.path);
|
||||
ckchs_transaction.path = NULL;
|
||||
ha_free(&ckchs_transaction.path);
|
||||
ckchs_transaction.new_ckchs = NULL;
|
||||
ckchs_transaction.old_ckchs = NULL;
|
||||
goto end;
|
||||
@ -1714,8 +1697,7 @@ static int cli_parse_set_cert(char **args, char *payload, struct appctx *appctx,
|
||||
|
||||
appctx->ctx.ssl.old_ckchs = NULL;
|
||||
|
||||
free(appctx->ctx.ssl.path);
|
||||
appctx->ctx.ssl.path = NULL;
|
||||
ha_free(&appctx->ctx.ssl.path);
|
||||
|
||||
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
|
||||
return cli_dynerr(appctx, memprintf(&err, "%sCan't update %s!\n", err ? err : "", args[3]));
|
||||
@ -1757,8 +1739,7 @@ static int cli_parse_abort_cert(char **args, char *payload, struct appctx *appct
|
||||
ckch_store_free(ckchs_transaction.new_ckchs);
|
||||
ckchs_transaction.new_ckchs = NULL;
|
||||
ckchs_transaction.old_ckchs = NULL;
|
||||
free(ckchs_transaction.path);
|
||||
ckchs_transaction.path = NULL;
|
||||
ha_free(&ckchs_transaction.path);
|
||||
|
||||
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
|
||||
|
||||
|
@ -35,29 +35,20 @@ void ssl_sock_free_ssl_conf(struct ssl_bind_conf *conf)
|
||||
{
|
||||
if (conf) {
|
||||
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
free(conf->npn_str);
|
||||
conf->npn_str = NULL;
|
||||
ha_free(&conf->npn_str);
|
||||
#endif
|
||||
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
|
||||
free(conf->alpn_str);
|
||||
conf->alpn_str = NULL;
|
||||
ha_free(&conf->alpn_str);
|
||||
#endif
|
||||
free(conf->ca_file);
|
||||
conf->ca_file = NULL;
|
||||
free(conf->ca_verify_file);
|
||||
conf->ca_verify_file = NULL;
|
||||
free(conf->crl_file);
|
||||
conf->crl_file = NULL;
|
||||
free(conf->ciphers);
|
||||
conf->ciphers = NULL;
|
||||
ha_free(&conf->ca_file);
|
||||
ha_free(&conf->ca_verify_file);
|
||||
ha_free(&conf->crl_file);
|
||||
ha_free(&conf->ciphers);
|
||||
#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
|
||||
free(conf->ciphersuites);
|
||||
conf->ciphersuites = NULL;
|
||||
ha_free(&conf->ciphersuites);
|
||||
#endif
|
||||
free(conf->curves);
|
||||
conf->curves = NULL;
|
||||
free(conf->ecdhe);
|
||||
conf->ecdhe = NULL;
|
||||
ha_free(&conf->curves);
|
||||
ha_free(&conf->ecdhe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,8 +421,7 @@ int crtlist_parse_line(char *line, char **crt_path, struct crtlist_entry *entry,
|
||||
crtlist_free_filters(entry->filters);
|
||||
entry->filters = NULL;
|
||||
ssl_sock_free_ssl_conf(entry->ssl_conf);
|
||||
free(entry->ssl_conf);
|
||||
entry->ssl_conf = NULL;
|
||||
ha_free(&entry->ssl_conf);
|
||||
return cfgerr;
|
||||
}
|
||||
|
||||
|
@ -2960,8 +2960,7 @@ void ssl_sock_load_cert_sni(struct ckch_inst *ckch_inst, struct bind_conf *bind_
|
||||
/* it's a duplicate, we should remove and free it */
|
||||
LIST_DEL(&sc0->by_ckch_inst);
|
||||
SSL_CTX_free(sc0->ctx);
|
||||
free(sc0);
|
||||
sc0 = NULL;
|
||||
ha_free(&sc0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4008,8 +4007,7 @@ static int ssl_sess_new_srv_cb(SSL *ssl, SSL_SESSION *sess)
|
||||
HA_RWLOCK_RDUNLOCK(SSL_SERVER_LOCK, &s->ssl_ctx.lock);
|
||||
} else {
|
||||
HA_RWLOCK_RDLOCK(SSL_SERVER_LOCK, &s->ssl_ctx.lock);
|
||||
free(s->ssl_ctx.reused_sess[tid].ptr);
|
||||
s->ssl_ctx.reused_sess[tid].ptr = NULL;
|
||||
ha_free(&s->ssl_ctx.reused_sess[tid].ptr);
|
||||
HA_RWLOCK_RDUNLOCK(SSL_SERVER_LOCK, &s->ssl_ctx.lock);
|
||||
}
|
||||
|
||||
@ -5151,8 +5149,7 @@ ssl_sock_free_ca(struct bind_conf *bind_conf)
|
||||
{
|
||||
if (bind_conf->ca_sign_ckch) {
|
||||
ssl_sock_free_cert_key_and_chain_contents(bind_conf->ca_sign_ckch);
|
||||
free(bind_conf->ca_sign_ckch);
|
||||
bind_conf->ca_sign_ckch = NULL;
|
||||
ha_free(&bind_conf->ca_sign_ckch);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5280,8 +5277,7 @@ static int ssl_sock_init(struct connection *conn, void **xprt_ctx)
|
||||
SSL_SESSION *sess = d2i_SSL_SESSION(NULL, &ptr, __objt_server(conn->target)->ssl_ctx.reused_sess[tid].size);
|
||||
if (sess && !SSL_set_session(ctx->ssl, sess)) {
|
||||
SSL_SESSION_free(sess);
|
||||
free(__objt_server(conn->target)->ssl_ctx.reused_sess[tid].ptr);
|
||||
__objt_server(conn->target)->ssl_ctx.reused_sess[tid].ptr = NULL;
|
||||
ha_free(&__objt_server(conn->target)->ssl_ctx.reused_sess[tid].ptr);
|
||||
} else if (sess) {
|
||||
SSL_SESSION_free(sess);
|
||||
}
|
||||
@ -5676,10 +5672,8 @@ static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
|
||||
* another thread */
|
||||
|
||||
HA_RWLOCK_RDLOCK(SSL_SERVER_LOCK, &s->ssl_ctx.lock);
|
||||
if (s->ssl_ctx.reused_sess[tid].ptr) {
|
||||
free(s->ssl_ctx.reused_sess[tid].ptr);
|
||||
s->ssl_ctx.reused_sess[tid].ptr = NULL;
|
||||
}
|
||||
if (s->ssl_ctx.reused_sess[tid].ptr)
|
||||
ha_free(&s->ssl_ctx.reused_sess[tid].ptr);
|
||||
HA_RWLOCK_RDUNLOCK(SSL_SERVER_LOCK, &s->ssl_ctx.lock);
|
||||
}
|
||||
|
||||
|
@ -5064,8 +5064,7 @@ static void deinit_stat_lines_per_thread(void)
|
||||
for (i = 0; i < STATS_DOMAIN_COUNT; ++i) {
|
||||
const int domain = domains[i];
|
||||
|
||||
free(stat_l[domain]);
|
||||
stat_l[domain] = NULL;
|
||||
ha_free(&stat_l[domain]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ static void stream_free(struct stream *s)
|
||||
__decl_thread(struct resolvers *resolvers = s->resolv_ctx.parent->arg.resolv.resolvers);
|
||||
|
||||
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
|
||||
free(s->resolv_ctx.hostname_dn); s->resolv_ctx.hostname_dn = NULL;
|
||||
ha_free(&s->resolv_ctx.hostname_dn);
|
||||
s->resolv_ctx.hostname_dn_len = 0;
|
||||
resolv_unlink_resolution(s->resolv_ctx.requester);
|
||||
HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock);
|
||||
|
@ -3474,9 +3474,8 @@ static int check_proxy_tcpcheck(struct proxy *px)
|
||||
goto out;
|
||||
}
|
||||
|
||||
free(px->check_command);
|
||||
free(px->check_path);
|
||||
px->check_command = px->check_path = NULL;
|
||||
ha_free(&px->check_command);
|
||||
ha_free(&px->check_path);
|
||||
|
||||
if (!px->tcpcheck_rules.list) {
|
||||
ha_alert("config : proxy '%s' : tcp-check configured but no ruleset defined.\n", px->id);
|
||||
@ -3546,10 +3545,8 @@ static int check_proxy_tcpcheck(struct proxy *px)
|
||||
* comment is assigned to the following rule(s).
|
||||
*/
|
||||
list_for_each_entry_safe(chk, back, px->tcpcheck_rules.list, list) {
|
||||
if (chk->action != prev_action && prev_action != TCPCHK_ACT_COMMENT) {
|
||||
free(comment);
|
||||
comment = NULL;
|
||||
}
|
||||
if (chk->action != prev_action && prev_action != TCPCHK_ACT_COMMENT)
|
||||
ha_free(&comment);
|
||||
|
||||
prev_action = chk->action;
|
||||
switch (chk->action) {
|
||||
@ -3564,8 +3561,7 @@ static int check_proxy_tcpcheck(struct proxy *px)
|
||||
chk->comment = strdup(comment);
|
||||
/* fall through */
|
||||
case TCPCHK_ACT_ACTION_KW:
|
||||
free(comment);
|
||||
comment = NULL;
|
||||
ha_free(&comment);
|
||||
break;
|
||||
case TCPCHK_ACT_SEND:
|
||||
case TCPCHK_ACT_EXPECT:
|
||||
@ -3574,8 +3570,7 @@ static int check_proxy_tcpcheck(struct proxy *px)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(comment);
|
||||
comment = NULL;
|
||||
ha_free(&comment);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
@ -4864,8 +4859,7 @@ int proxy_parse_httpchk_opt(char **args, int cur_arg, struct proxy *curpx, const
|
||||
if (errmsg) {
|
||||
ha_warning("parsing [%s:%d]: '%s %s' : %s\n", file, line, args[0], args[1], errmsg);
|
||||
err_code |= ERR_WARN;
|
||||
free(errmsg);
|
||||
errmsg = NULL;
|
||||
ha_free(&errmsg);
|
||||
}
|
||||
|
||||
no_request:
|
||||
|
@ -2464,10 +2464,8 @@ int parse_binary(const char *source, char **binstr, int *binstrlen, char **err)
|
||||
|
||||
bad_input:
|
||||
memprintf(err, "an hex digit is expected (found '%c')", p[i-1]);
|
||||
if (alloc) {
|
||||
free(*binstr);
|
||||
*binstr = NULL;
|
||||
}
|
||||
if (alloc)
|
||||
ha_free(binstr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3957,8 +3955,7 @@ char *memvprintf(char **out, const char *format, va_list orig_args)
|
||||
|
||||
if (needed < 0) {
|
||||
/* an error was encountered */
|
||||
free(ret);
|
||||
ret = NULL;
|
||||
ha_free(&ret);
|
||||
}
|
||||
|
||||
if (out) {
|
||||
|
@ -406,10 +406,8 @@ static void ha_wurfl_deinit(void)
|
||||
send_log(NULL, LOG_NOTICE, "WURFL: Unloading module v.%s\n", HA_WURFL_MODULE_VERSION);
|
||||
wurfl_destroy(global_wurfl.handle);
|
||||
global_wurfl.handle = NULL;
|
||||
free(global_wurfl.data_file);
|
||||
global_wurfl.data_file = NULL;
|
||||
free(global_wurfl.cache_size);
|
||||
global_wurfl.cache_size = NULL;
|
||||
ha_free(&global_wurfl.data_file);
|
||||
ha_free(&global_wurfl.cache_size);
|
||||
|
||||
list_for_each_entry_safe(wi, wi2, &global_wurfl.information_list, list) {
|
||||
LIST_DEL(&wi->list);
|
||||
|
@ -2342,8 +2342,7 @@ static void quic_conn_enc_level_uninit(struct quic_enc_level *qel)
|
||||
qel->tx.crypto.bufs[i] = NULL;
|
||||
}
|
||||
}
|
||||
free(qel->tx.crypto.bufs);
|
||||
qel->tx.crypto.bufs = NULL;
|
||||
ha_free(&qel->tx.crypto.bufs);
|
||||
}
|
||||
|
||||
/* Initialize QUIC TLS encryption level with <level<> as level for <qc> QUIC
|
||||
@ -2384,8 +2383,7 @@ static int quic_conn_enc_level_init(struct quic_conn *qc,
|
||||
return 1;
|
||||
|
||||
err:
|
||||
free(qel->tx.crypto.bufs);
|
||||
qel->tx.crypto.bufs = NULL;
|
||||
ha_free(&qel->tx.crypto.bufs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2405,10 +2403,8 @@ static inline void free_quic_conn_tx_bufs(struct q_buf **bufs, size_t nb)
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
free((*p)->area);
|
||||
(*p)->area = NULL;
|
||||
free(*p);
|
||||
*p = NULL;
|
||||
ha_free(&(*p)->area);
|
||||
ha_free(p);
|
||||
p++;
|
||||
}
|
||||
free(bufs);
|
||||
|
Loading…
Reference in New Issue
Block a user