summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-22 13:12:28 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-22 13:12:28 +0000
commit2b2b1655a6abf33c76f1320940f06d2aac91b41d (patch)
tree0861bd57f912d2b560d9454dac5f3149c9cbb586
parent238dfb18dbb84c98252d701fd30acc846be6f80a (diff)
-avoid calling memmove with NULL argument
-rw-r--r--src/microhttpd/memorypool.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 8d679854..037cbf57 100644
--- 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;