libmicrohttpd

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

commit 2b2b1655a6abf33c76f1320940f06d2aac91b41d
parent 238dfb18dbb84c98252d701fd30acc846be6f80a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 22 Aug 2016 13:12:28 +0000

-avoid calling memmove with NULL argument

Diffstat:
Msrc/microhttpd/memorypool.c | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c @@ -241,7 +241,8 @@ MHD_pool_reallocate (struct MemoryPool *pool, { /* fits */ ret = &pool->memory[pool->pos]; - memmove (ret, old, old_size); + if (0 != old_size) + memmove (ret, old, old_size); pool->pos += asize; return ret; } @@ -273,17 +274,19 @@ MHD_pool_reset (struct MemoryPool *pool, { if (keep != pool->memory) { - memmove (pool->memory, - keep, - copy_bytes); + if (0 != copy_bytes) + memmove (pool->memory, + keep, + copy_bytes); keep = pool->memory; } } pool->end = pool->size; /* technically not needed, but safer to zero out */ - memset (&pool->memory[copy_bytes], - 0, - pool->size - copy_bytes); + 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;