add logic to check return value of MHD_pool_reallocate()

This commit is contained in:
Christian Grothoff
2020-08-19 09:41:31 +02:00
parent bade8d9c4b
commit 773d6cce73
2 changed files with 20 additions and 4 deletions
+4
View File
@@ -1,3 +1,7 @@
Wed 19 Aug 2020 09:40:39 AM CEST
Add logic to check on MHD_pool_reallocate() failure reported on the
mailinglist (will NOT yet fix the issue). -CG
Sun 26 Jul 2020 01:56:54 PM CEST
Add MHD_create_response_from_pipe() to allow creating a response based
on data read from a pipe. -CG
+16 -4
View File
@@ -1147,6 +1147,7 @@ try_grow_read_buffer (struct MHD_Connection *connection,
{
size_t new_size;
size_t avail_size;
void *rb;
avail_size = MHD_pool_get_free (connection->pool);
if (0 == avail_size)
@@ -1175,10 +1176,21 @@ try_grow_read_buffer (struct MHD_Connection *connection,
new_size = connection->read_buffer_size + grow_size;
}
/* we can actually grow the buffer, do it! */
connection->read_buffer = MHD_pool_reallocate (connection->pool,
connection->read_buffer,
connection->read_buffer_size,
new_size);
rb = MHD_pool_reallocate (connection->pool,
connection->read_buffer,
connection->read_buffer_size,
new_size);
if (NULL == rb)
{
/* This should NOT be possible: we just computed 'new_size' so that
it should fit. If it happens, somehow our read buffer is not in
the right position in the pool, say because someone called
MHD_pool_allocate() without 'from_end' set to 'true'? Anyway,
should be investigated! (Ideally provide all data from
*pool and connection->read_buffer and new_size for debugging). */mhd_assert (0);
return false;
}
connection->read_buffer = rb;
mhd_assert (NULL != connection->read_buffer);
connection->read_buffer_size = new_size;
return true;