aboutsummaryrefslogtreecommitdiff
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)
downloadlibmicrohttpd-2b2b1655a6abf33c76f1320940f06d2aac91b41d.tar.gz
libmicrohttpd-2b2b1655a6abf33c76f1320940f06d2aac91b41d.zip
-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,
241 { 241 {
242 /* fits */ 242 /* fits */
243 ret = &pool->memory[pool->pos]; 243 ret = &pool->memory[pool->pos];
244 memmove (ret, old, old_size); 244 if (0 != old_size)
245 memmove (ret, old, old_size);
245 pool->pos += asize; 246 pool->pos += asize;
246 return ret; 247 return ret;
247 } 248 }
@@ -273,17 +274,19 @@ MHD_pool_reset (struct MemoryPool *pool,
273 { 274 {
274 if (keep != pool->memory) 275 if (keep != pool->memory)
275 { 276 {
276 memmove (pool->memory, 277 if (0 != copy_bytes)
277 keep, 278 memmove (pool->memory,
278 copy_bytes); 279 keep,
280 copy_bytes);
279 keep = pool->memory; 281 keep = pool->memory;
280 } 282 }
281 } 283 }
282 pool->end = pool->size; 284 pool->end = pool->size;
283 /* technically not needed, but safer to zero out */ 285 /* technically not needed, but safer to zero out */
284 memset (&pool->memory[copy_bytes], 286 if (pool->size > copy_bytes)
285 0, 287 memset (&pool->memory[copy_bytes],
286 pool->size - copy_bytes); 288 0,
289 pool->size - copy_bytes);
287 if (NULL != keep) 290 if (NULL != keep)
288 pool->pos = ROUND_TO_ALIGN (new_size); 291 pool->pos = ROUND_TO_ALIGN (new_size);
289 return keep; 292 return keep;