commit de02ef1342611a724faa4ced850c2408bb9b5f64
parent a532889effefc492c202d83cd70f439db49504ff
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sun, 31 Dec 2023 12:12:52 +0100
initialize required_bytes on all code paths to avoid false-positive compiler warning
Diffstat:
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
@@ -470,7 +470,7 @@ MHD_pool_is_resizable_inplace (struct MemoryPool *pool,
* @param size the size of memory in bytes to allocate
* @param[out] required_bytes the pointer to variable to be updated with
* the size of the required additional free
- * memory area, not updated if function succeed.
+ * memory area, set to 0 if function succeeds.
* Cannot be NULL.
* @return the pointer to allocated memory area if succeed,
* NULL if the pool doesn't have enough space, required_bytes is updated
@@ -504,6 +504,7 @@ MHD_pool_try_alloc (struct MemoryPool *pool,
*required_bytes = SIZE_MAX;
return NULL;
}
+ *required_bytes = 0;
ret = &pool->memory[pool->end - asize];
pool->end -= asize;
_MHD_UNPOISON_MEMORY (ret, size);
diff --git a/src/microhttpd/memorypool.h b/src/microhttpd/memorypool.h
@@ -114,7 +114,7 @@ MHD_pool_is_resizable_inplace (struct MemoryPool *pool,
* @param size the size of memory in bytes to allocate
* @param[out] required_bytes the pointer to variable to be updated with
* the size of the required additional free
- * memory area, not updated if function succeed.
+ * memory area, set to 0 if function succeeds.
* Cannot be NULL.
* @return the pointer to allocated memory area if succeed,
* NULL if the pool doesn't have enough space, required_bytes is updated