aboutsummaryrefslogtreecommitdiff
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)
downloadlibmicrohttpd-d15bd7c02f30b612a2c2776f21209a6bc8fa00b9.tar.gz
libmicrohttpd-d15bd7c02f30b612a2c2776f21209a6bc8fa00b9.zip
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 @@
40#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) 40#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
41#define MAP_ANONYMOUS MAP_ANON 41#define MAP_ANONYMOUS MAP_ANON
42#endif 42#endif
43#ifndef MAP_FAILED 43#if defined(_WIN32)
44#define MAP_FAILED NULL
45#elif ! defined(MAP_FAILED)
44#define MAP_FAILED ((void*)-1) 46#define MAP_FAILED ((void*)-1)
45#endif 47#endif
46 48
@@ -78,7 +80,7 @@ struct MemoryPool
78 size_t pos; 80 size_t pos;
79 81
80 /** 82 /**
81 * Offset of the last unallocated byte. 83 * Offset of the byte after the last unallocated byte.
82 */ 84 */
83 size_t end; 85 size_t end;
84 86
@@ -100,6 +102,7 @@ MHD_pool_create (size_t max)
100{ 102{
101 struct MemoryPool *pool; 103 struct MemoryPool *pool;
102 104
105 max = ROUND_TO_ALIGN(max);
103 pool = malloc (sizeof (struct MemoryPool)); 106 pool = malloc (sizeof (struct MemoryPool));
104 if (NULL == pool) 107 if (NULL == pool)
105 return NULL; 108 return NULL;