mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-22 14:49:45 -04:00
BUG/MINOR: httpclient: check if hdr_num is not 0
Check if hdr_num is not 0 before allocating or copying the headers to the hc->hdrs space.
This commit is contained in:
parent
dfc3f8906d
commit
0d6f7790fb
1 changed files with 10 additions and 8 deletions
|
|
@ -533,15 +533,17 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
|
|||
hdr_num++;
|
||||
}
|
||||
|
||||
/* alloc and copy the headers in the httpclient struct */
|
||||
hc->res.hdrs = calloc((hdr_num + 1), sizeof(*hc->res.hdrs));
|
||||
if (!hc->res.hdrs)
|
||||
goto end;
|
||||
memcpy(hc->res.hdrs, hdrs, sizeof(struct http_hdr) * (hdr_num + 1));
|
||||
if (hdr_num) {
|
||||
/* alloc and copy the headers in the httpclient struct */
|
||||
hc->res.hdrs = calloc((hdr_num + 1), sizeof(*hc->res.hdrs));
|
||||
if (!hc->res.hdrs)
|
||||
goto end;
|
||||
memcpy(hc->res.hdrs, hdrs, sizeof(struct http_hdr) * (hdr_num + 1));
|
||||
|
||||
/* caller callback */
|
||||
if (hc->ops.res_headers)
|
||||
hc->ops.res_headers(hc);
|
||||
/* caller callback */
|
||||
if (hc->ops.res_headers)
|
||||
hc->ops.res_headers(hc);
|
||||
}
|
||||
|
||||
/* if there is no HTX data anymore and the EOM flag is
|
||||
* set, leave (no body) */
|
||||
|
|
|
|||
Loading…
Reference in a new issue