libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit d15bd7c02f30b612a2c2776f21209a6bc8fa00b9
parent 1430529713674acda1c16112d57c506dbd0c9f8e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Wed, 12 Jun 2019 19:46:42 +0300

memorypool: fixed possible crash if failed to allocate memory on W32

Diffstat:
Msrc/microhttpd/memorypool.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 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;