commit c375e5aa1cb4e5976b98470e840d8ebc99bf5d14
parent 56b131d9ec5f04f9d16b42886fb942eb378bfd16
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 7 Jun 2022 19:51:20 +0300
Partial revert of 82abaee62f000d379646ee412af45a1f8a1ddc87
No need to process part of code if some variables length are zeros.
Non-NULL pointers can point to zero-length strings, but if pointer is
NULL the length is always zero.
For example 'req_body' could be not be NULL, but as long as
'req_body_size' is zero, no chunk must be added.
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/microhttpd/test_set_panic.c b/src/microhttpd/test_set_panic.c
@@ -553,11 +553,9 @@ _MHD_dumbClient_create (uint16_t port, const char *method, const char *url,
": chunked\r\n");
}
}
- if (NULL != add_headers)
+ if (0 != add_hdrs_size)
{
- memcpy (send_buf + clnt->req_size,
- add_headers,
- add_hdrs_size);
+ memcpy (send_buf + clnt->req_size, add_headers, add_hdrs_size);
clnt->req_size += add_hdrs_size;
}
/* Terminate header */
@@ -567,7 +565,7 @@ _MHD_dumbClient_create (uint16_t port, const char *method, const char *url,
/* Add body (if any) */
if (! chunked)
{
- if (NULL != req_body)
+ if (0 != req_body_size)
{
memcpy (send_buf + clnt->req_size, req_body, req_body_size);
clnt->req_size += req_body_size;
@@ -575,7 +573,7 @@ _MHD_dumbClient_create (uint16_t port, const char *method, const char *url,
}
else
{
- if (NULL != req_body)
+ if (0 != req_body_size)
{
int prn_size;
prn_size = snprintf (send_buf + clnt->req_size,