aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-09-29 15:19:02 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-10-03 21:08:01 +0300
commit16f6b9460c6da8f32848bfdfd09cebf8f48d14b5 (patch)
tree42b396cc256dc7683e9f870a02619c11af201a02 /src
parent3d10823017ebb69d92c1c4b3ac5d663b257eacb4 (diff)
downloadlibmicrohttpd-16f6b9460c6da8f32848bfdfd09cebf8f48d14b5.tar.gz
libmicrohttpd-16f6b9460c6da8f32848bfdfd09cebf8f48d14b5.zip
connection_alloc_memory(): fixed missing update of buffers sizes
Diffstat (limited to 'src')
-rw-r--r--src/microhttpd/connection.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 0e0fd5d4..47f9a6ae 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -221,14 +221,18 @@ connection_alloc_memory (struct MHD_Connection *connection,
221 if (c->write_buffer_size - c->write_buffer_append_offset >= need_to_free) 221 if (c->write_buffer_size - c->write_buffer_append_offset >= need_to_free)
222 { 222 {
223 char *buf; 223 char *buf;
224 const size_t new_buf_size = c->write_buffer_size - need_to_free;
224 buf = MHD_pool_reallocate (pool, 225 buf = MHD_pool_reallocate (pool,
225 c->write_buffer, 226 c->write_buffer,
226 c->write_buffer_size, 227 c->write_buffer_size,
227 c->write_buffer_size - need_to_free); 228 new_buf_size);
228 mhd_assert (c->write_buffer == buf); 229 mhd_assert (c->write_buffer == buf);
229#ifdef NDEBUG 230#ifdef NDEBUG
230 (void) buf; /* mute compiler warning */ 231 (void) buf; /* mute compiler warning */
231#endif 232#endif
233 mhd_assert (c->write_buffer_append_offset <= new_buf_size);
234 mhd_assert (c->write_buffer_send_offset <= new_buf_size);
235 c->write_buffer_size = new_buf_size;
232 } 236 }
233 else 237 else
234 return NULL; 238 return NULL;
@@ -239,14 +243,17 @@ connection_alloc_memory (struct MHD_Connection *connection,
239 if (c->read_buffer_size - c->read_buffer_offset >= need_to_free) 243 if (c->read_buffer_size - c->read_buffer_offset >= need_to_free)
240 { 244 {
241 char *buf; 245 char *buf;
246 const size_t new_buf_size = c->read_buffer_size - need_to_free;
242 buf = MHD_pool_reallocate (pool, 247 buf = MHD_pool_reallocate (pool,
243 c->read_buffer, 248 c->read_buffer,
244 c->read_buffer_size, 249 c->read_buffer_size,
245 c->read_buffer_size - need_to_free); 250 new_buf_size);
246 mhd_assert (c->read_buffer == buf); 251 mhd_assert (c->read_buffer == buf);
247#ifdef NDEBUG 252#ifdef NDEBUG
248 (void) buf; /* mute compiler warning */ 253 (void) buf; /* mute compiler warning */
249#endif 254#endif
255 mhd_assert (c->read_buffer_offset <= new_buf_size);
256 c->read_buffer_size = new_buf_size;
250 } 257 }
251 else 258 else
252 return NULL; 259 return NULL;