Skip to content

Commit

Permalink
CLEANUP: Re-apply xalloc_size.cocci (3)
Browse files Browse the repository at this point in the history
This reapplies the xalloc_size.cocci patch across the whole `src/` tree.

see 16cc16d
see 63ee0e4
see 9fb57e8
  • Loading branch information
TimWolla authored and wtarreau committed Nov 6, 2023
1 parent ff3dcb2 commit d7eaa0d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@ static int postcheck_log_backend(struct proxy *be)
/* alloc srv array (it will be used for active and backup server lists in turn,
* so we ensure that the longest list will fit
*/
be->lbprm.log.srv = calloc(MAX(be->srv_act, be->srv_bck), sizeof(struct server *));
be->lbprm.log.srv = calloc(MAX(be->srv_act, be->srv_bck),
sizeof(*be->lbprm.log.srv));

if (!be->lbprm.log.srv ) {
memprintf(&msg, "memory error when allocating server array (%d entries)",
Expand Down
2 changes: 1 addition & 1 deletion src/proto_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static int quic_alloc_dghdlrs(void)
MT_LIST_INIT(&dghdlr->dgrams);
}

quic_cid_trees = calloc(QUIC_CID_TREES_CNT, sizeof(struct quic_cid_tree));
quic_cid_trees = calloc(QUIC_CID_TREES_CNT, sizeof(*quic_cid_trees));
if (!quic_cid_trees) {
ha_alert("Failed to allocate global CIDs trees.\n");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ static int srv_parse_set_proxy_v2_tlv_fmt(char **args, int *cur_arg,
}
}

srv_tlv = malloc(sizeof(struct srv_pp_tlv_list));
srv_tlv = malloc(sizeof(*srv_tlv));
if (unlikely(!srv_tlv)) {
memprintf(err, "'%s' : failed to parse allocate TLV entry", args[*cur_arg]);
goto fail;
Expand Down Expand Up @@ -2516,7 +2516,7 @@ void srv_settings_cpy(struct server *srv, const struct server *src, int srv_tmpl
list_for_each_entry(srv_tlv, &src->pp_tlvs, list) {
if (srv_tlv == NULL)
break;
new_srv_tlv = malloc(sizeof(struct srv_pp_tlv_list));
new_srv_tlv = malloc(sizeof(*new_srv_tlv));
if (unlikely(!new_srv_tlv)) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tcpcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -4270,7 +4270,7 @@ int proxy_parse_smtpchk_opt(char **args, int cur_arg, struct proxy *curpx, const
(strcmp(args[cur_arg], "EHLO") == 0 || strcmp(args[cur_arg], "HELO") == 0)) {
/* <EHLO|HELO> + space (1) + <host> + null byte (1) */
size_t len = strlen(args[cur_arg]) + 1 + strlen(args[cur_arg+1]) + 1;
cmd = calloc(len, 1);
cmd = calloc(1, len);
if (cmd)
snprintf(cmd, len, "%s %s", args[cur_arg], args[cur_arg+1]);
}
Expand Down

0 comments on commit d7eaa0d

Please sign in to comment.