aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/response.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r--src/microhttpd/response.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 17fe8122..8b89c5f0 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -38,6 +38,7 @@
38#include "mhd_itc.h" 38#include "mhd_itc.h"
39#include "connection.h" 39#include "connection.h"
40#include "memorypool.h" 40#include "memorypool.h"
41#include "mhd_compat.h"
41 42
42 43
43#if defined(_WIN32) && defined(MHD_W32_MUTEX_) 44#if defined(_WIN32) && defined(MHD_W32_MUTEX_)
@@ -270,11 +271,8 @@ MHD_create_response_from_callback (uint64_t size,
270 271
271 if ((NULL == crc) || (0 == block_size)) 272 if ((NULL == crc) || (0 == block_size))
272 return NULL; 273 return NULL;
273 if (NULL == (response = malloc (sizeof (struct MHD_Response) + block_size))) 274 if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response) + block_size)))
274 return NULL; 275 return NULL;
275 memset (response,
276 0,
277 sizeof (struct MHD_Response));
278 response->fd = -1; 276 response->fd = -1;
279 response->data = (void *) &response[1]; 277 response->data = (void *) &response[1];
280 response->data_buffer_size = block_size; 278 response->data_buffer_size = block_size;
@@ -554,11 +552,8 @@ MHD_create_response_from_data (size_t size,
554 552
555 if ((NULL == data) && (size > 0)) 553 if ((NULL == data) && (size > 0))
556 return NULL; 554 return NULL;
557 if (NULL == (response = malloc (sizeof (struct MHD_Response)))) 555 if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response))))
558 return NULL; 556 return NULL;
559 memset (response,
560 0,
561 sizeof (struct MHD_Response));
562 response->fd = -1; 557 response->fd = -1;
563 if (! MHD_mutex_init_ (&response->mutex)) 558 if (! MHD_mutex_init_ (&response->mutex))
564 { 559 {
@@ -706,12 +701,9 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
706 return MHD_NO; 701 return MHD_NO;
707 } 702 }
708 703
709 urh = malloc (sizeof (struct MHD_UpgradeResponseHandle)); 704 urh = MHD_calloc_ (1, sizeof (struct MHD_UpgradeResponseHandle));
710 if (NULL == urh) 705 if (NULL == urh)
711 return MHD_NO; 706 return MHD_NO;
712 memset (urh,
713 0,
714 sizeof (struct MHD_UpgradeResponseHandle));
715 urh->connection = connection; 707 urh->connection = connection;
716 rbo = connection->read_buffer_offset; 708 rbo = connection->read_buffer_offset;
717 connection->read_buffer_offset = 0; 709 connection->read_buffer_offset = 0;
@@ -960,10 +952,9 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler,
960 952
961 if (NULL == upgrade_handler) 953 if (NULL == upgrade_handler)
962 return NULL; /* invalid request */ 954 return NULL; /* invalid request */
963 response = malloc (sizeof (struct MHD_Response)); 955 response = MHD_calloc_ (1, sizeof (struct MHD_Response));
964 if (NULL == response) 956 if (NULL == response)
965 return NULL; 957 return NULL;
966 memset (response, 0, sizeof (struct MHD_Response));
967 if (! MHD_mutex_init_ (&response->mutex)) 958 if (! MHD_mutex_init_ (&response->mutex))
968 { 959 {
969 free (response); 960 free (response);