aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-10-06 19:23:39 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-10-07 11:23:47 +0300
commit8a1ae1caf34c3d468dc96cd1c8681d93e265ff10 (patch)
tree9cb45ae3c5878892c871bef2308435722e3cd43a
parent7eb3139e9a65cc666a976b7eb811dd9fcb7f5099 (diff)
downloadlibmicrohttpd-8a1ae1caf34c3d468dc96cd1c8681d93e265ff10.tar.gz
libmicrohttpd-8a1ae1caf34c3d468dc96cd1c8681d93e265ff10.zip
memorypool: more sanity checks
-rw-r--r--src/microhttpd/memorypool.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 4d619464..a979c64a 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -98,6 +98,7 @@ MHD_init_mem_pools_ (void)
98#else 98#else
99 MHD_sys_page_size_ = MHD_DEF_PAGE_SIZE_; 99 MHD_sys_page_size_ = MHD_DEF_PAGE_SIZE_;
100#endif /* _WIN32 */ 100#endif /* _WIN32 */
101 mhd_assert (0 == (MHD_sys_page_size_ % ALIGN_SIZE));
101} 102}
102 103
103 104
@@ -147,6 +148,7 @@ MHD_pool_create (size_t max)
147 struct MemoryPool *pool; 148 struct MemoryPool *pool;
148 size_t alloc_size; 149 size_t alloc_size;
149 150
151 mhd_assert (max > 0);
150 pool = malloc (sizeof (struct MemoryPool)); 152 pool = malloc (sizeof (struct MemoryPool));
151 if (NULL == pool) 153 if (NULL == pool)
152 return NULL; 154 return NULL;
@@ -195,6 +197,7 @@ MHD_pool_create (size_t max)
195 pool->is_mmap = true; 197 pool->is_mmap = true;
196 } 198 }
197#endif /* _WIN32 || MAP_ANONYMOUS */ 199#endif /* _WIN32 || MAP_ANONYMOUS */
200 mhd_assert (0 == (((uintptr_t) pool->memory) % ALIGN_SIZE));
198 pool->pos = 0; 201 pool->pos = 0;
199 pool->end = alloc_size; 202 pool->end = alloc_size;
200 pool->size = alloc_size; 203 pool->size = alloc_size;