libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit c98aa3d33472f82014e9cd80d1a3bf0ee9fe80c1
parent d12ed49fd33d991639512ee7637bfc644da3f123
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 16 Jun 2019 17:49:35 +0300

memorypool: fixed MHD_pool_reset()

Diffstat:
Msrc/microhttpd/memorypool.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c @@ -331,6 +331,7 @@ MHD_pool_reset (struct MemoryPool *pool, { mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); + mhd_assert (copy_bytes < new_size); mhd_assert (keep != NULL || copy_bytes == 0); mhd_assert (keep == NULL || pool->memory <= (uint8_t*)keep); mhd_assert (keep == NULL || pool->memory + pool->size >= (uint8_t*)keep + copy_bytes); @@ -341,17 +342,15 @@ MHD_pool_reset (struct MemoryPool *pool, memmove (pool->memory, keep, copy_bytes); - keep = pool->memory; } - pool->end = pool->size; /* technically not needed, but safer to zero out */ if (pool->size > copy_bytes) memset (&pool->memory[copy_bytes], 0, pool->size - copy_bytes); - if (NULL != keep) - pool->pos = ROUND_TO_ALIGN (new_size); - return keep; + pool->pos = ROUND_TO_ALIGN (new_size); + pool->end = pool->size; + return pool->memory; }