aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index ceae1cf8..6666be94 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1147,6 +1147,7 @@ try_grow_read_buffer (struct MHD_Connection *connection,
1147{ 1147{
1148 size_t new_size; 1148 size_t new_size;
1149 size_t avail_size; 1149 size_t avail_size;
1150 void *rb;
1150 1151
1151 avail_size = MHD_pool_get_free (connection->pool); 1152 avail_size = MHD_pool_get_free (connection->pool);
1152 if (0 == avail_size) 1153 if (0 == avail_size)
@@ -1175,10 +1176,21 @@ try_grow_read_buffer (struct MHD_Connection *connection,
1175 new_size = connection->read_buffer_size + grow_size; 1176 new_size = connection->read_buffer_size + grow_size;
1176 } 1177 }
1177 /* we can actually grow the buffer, do it! */ 1178 /* we can actually grow the buffer, do it! */
1178 connection->read_buffer = MHD_pool_reallocate (connection->pool, 1179 rb = MHD_pool_reallocate (connection->pool,
1179 connection->read_buffer, 1180 connection->read_buffer,
1180 connection->read_buffer_size, 1181 connection->read_buffer_size,
1181 new_size); 1182 new_size);
1183 if (NULL == rb)
1184 {
1185 /* This should NOT be possible: we just computed 'new_size' so that
1186 it should fit. If it happens, somehow our read buffer is not in
1187 the right position in the pool, say because someone called
1188 MHD_pool_allocate() without 'from_end' set to 'true'? Anyway,
1189 should be investigated! (Ideally provide all data from
1190 *pool and connection->read_buffer and new_size for debugging). */mhd_assert (0);
1191 return false;
1192 }
1193 connection->read_buffer = rb;
1182 mhd_assert (NULL != connection->read_buffer); 1194 mhd_assert (NULL != connection->read_buffer);
1183 connection->read_buffer_size = new_size; 1195 connection->read_buffer_size = new_size;
1184 return true; 1196 return true;