aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-12-31 12:12:52 +0100
committerChristian Grothoff <grothoff@gnunet.org>2023-12-31 12:12:52 +0100
commitde02ef1342611a724faa4ced850c2408bb9b5f64 (patch)
treea6a0c210fb8d291fa053cca44805e0082645d820
parenta532889effefc492c202d83cd70f439db49504ff (diff)
downloadlibmicrohttpd-de02ef1342611a724faa4ced850c2408bb9b5f64.tar.gz
libmicrohttpd-de02ef1342611a724faa4ced850c2408bb9b5f64.zip
initialize required_bytes on all code paths to avoid false-positive compiler warning
-rw-r--r--src/microhttpd/memorypool.c3
-rw-r--r--src/microhttpd/memorypool.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index fbc94659..41503f63 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -470,7 +470,7 @@ MHD_pool_is_resizable_inplace (struct MemoryPool *pool,
470 * @param size the size of memory in bytes to allocate 470 * @param size the size of memory in bytes to allocate
471 * @param[out] required_bytes the pointer to variable to be updated with 471 * @param[out] required_bytes the pointer to variable to be updated with
472 * the size of the required additional free 472 * the size of the required additional free
473 * memory area, not updated if function succeed. 473 * memory area, set to 0 if function succeeds.
474 * Cannot be NULL. 474 * Cannot be NULL.
475 * @return the pointer to allocated memory area if succeed, 475 * @return the pointer to allocated memory area if succeed,
476 * NULL if the pool doesn't have enough space, required_bytes is updated 476 * NULL if the pool doesn't have enough space, required_bytes is updated
@@ -504,6 +504,7 @@ MHD_pool_try_alloc (struct MemoryPool *pool,
504 *required_bytes = SIZE_MAX; 504 *required_bytes = SIZE_MAX;
505 return NULL; 505 return NULL;
506 } 506 }
507 *required_bytes = 0;
507 ret = &pool->memory[pool->end - asize]; 508 ret = &pool->memory[pool->end - asize];
508 pool->end -= asize; 509 pool->end -= asize;
509 _MHD_UNPOISON_MEMORY (ret, size); 510 _MHD_UNPOISON_MEMORY (ret, size);
diff --git a/src/microhttpd/memorypool.h b/src/microhttpd/memorypool.h
index 18c8e63c..a9af78a9 100644
--- a/src/microhttpd/memorypool.h
+++ b/src/microhttpd/memorypool.h
@@ -114,7 +114,7 @@ MHD_pool_is_resizable_inplace (struct MemoryPool *pool,
114 * @param size the size of memory in bytes to allocate 114 * @param size the size of memory in bytes to allocate
115 * @param[out] required_bytes the pointer to variable to be updated with 115 * @param[out] required_bytes the pointer to variable to be updated with
116 * the size of the required additional free 116 * the size of the required additional free
117 * memory area, not updated if function succeed. 117 * memory area, set to 0 if function succeeds.
118 * Cannot be NULL. 118 * Cannot be NULL.
119 * @return the pointer to allocated memory area if succeed, 119 * @return the pointer to allocated memory area if succeed,
120 * NULL if the pool doesn't have enough space, required_bytes is updated 120 * NULL if the pool doesn't have enough space, required_bytes is updated