summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-12 19:46:42 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-12 19:46:42 +0300
commitd15bd7c02f30b612a2c2776f21209a6bc8fa00b9 (patch)
treea4c95015675e72451b41de363222c5a423349168
parent1430529713674acda1c16112d57c506dbd0c9f8e (diff)
memorypool: fixed possible crash if failed to allocate memory on W32
-rw-r--r--src/microhttpd/memorypool.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 843dd540..e3de5841 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -40,7 +40,9 @@
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
-#ifndef MAP_FAILED
+#if defined(_WIN32)
+#define MAP_FAILED NULL
+#elif ! defined(MAP_FAILED)
#define MAP_FAILED ((void*)-1)
#endif
@@ -78,7 +80,7 @@ struct MemoryPool
size_t pos;
/**
- * Offset of the last unallocated byte.
+ * Offset of the byte after the last unallocated byte.
*/
size_t end;
@@ -100,6 +102,7 @@ MHD_pool_create (size_t max)
{
struct MemoryPool *pool;
+ max = ROUND_TO_ALIGN(max);
pool = malloc (sizeof (struct MemoryPool));
if (NULL == pool)
return NULL;