mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: Fix type passed of sizeof() for calloc()
newsrv->curr_idle_thr is of type `unsigned int`, not `int`. Fix this issue by simply passing the dereferenced pointer to sizeof, which is the preferred style anyway. This bug was introduced in commitdc2f2753e9
. It first appeared in 2.2-dev5. The patch must be backported to 2.2+. It is notable that the `calloc` call was not introduced within the commit in question. The allocation was already happening before that commit and it already looked like it does after applying the patch. Apparently the argument for the `sizeof` managed to get broken during the rearrangement that happened in that commit: for (i = 0; i < global.nbthread; i++) - MT_LIST_INIT(&newsrv->idle_orphan_conns[i]); - newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr)); + MT_LIST_INIT(&newsrv->safe_conns[i]); + + newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(int)); Even more notable is that I previously fixed that *exact same* allocation in commit017484c80f
. So apparently it was managed to break this single line twice in the same way for whatever reason there might be.
This commit is contained in:
parent
d344910677
commit
b53dd03dc0
@ -3611,7 +3611,7 @@ int check_config_validity()
|
||||
for (i = 0; i < global.nbthread; i++)
|
||||
MT_LIST_INIT(&newsrv->safe_conns[i]);
|
||||
|
||||
newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(int));
|
||||
newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr));
|
||||
if (!newsrv->curr_idle_thr)
|
||||
goto err;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user