From 4524fbe23f82662ab80107a430fc0384cd2230c7 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Fri, 8 Oct 2021 10:14:58 +0300 Subject: Added missing update of connection's read buffer size --- src/microhttpd/connection.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/microhttpd') diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 536bb28f..654e4192 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -3683,10 +3683,17 @@ MHD_connection_handle_read (struct MHD_Connection *connection) #endif /* UPGRADE_SUPPORT */ default: /* shrink read buffer to how much is actually used */ - MHD_pool_reallocate (connection->pool, - connection->read_buffer, - connection->read_buffer_size, - connection->read_buffer_offset); + if ((0 != connection->read_buffer_size) && + (connection->read_buffer_size != connection->read_buffer_offset)) + { + mhd_assert (NULL != connection->read_buffer); + connection->read_buffer = + MHD_pool_reallocate (connection->pool, + connection->read_buffer, + connection->read_buffer_size, + connection->read_buffer_offset); + connection->read_buffer_size = connection->read_buffer_offset; + } break; } return; -- cgit v1.2.3