diff options
Diffstat (limited to 'src/microhttpd/memorypool.c')
-rw-r--r-- | src/microhttpd/memorypool.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c index 4a890967..20ab4908 100644 --- a/src/microhttpd/memorypool.c +++ b/src/microhttpd/memorypool.c | |||
@@ -268,7 +268,7 @@ MHD_pool_reallocate (struct MemoryPool *pool, | |||
268 | /* Blocks "from the end" must not be reallocated */ | 268 | /* Blocks "from the end" must not be reallocated */ |
269 | mhd_assert (old == NULL || pool->memory + pool->pos > (uint8_t*)old); | 269 | mhd_assert (old == NULL || pool->memory + pool->pos > (uint8_t*)old); |
270 | 270 | ||
271 | if (pool->memory + new_size + 2 * ALIGN_SIZE< pool->memory) | 271 | if (new_size + 2 * ALIGN_SIZE < new_size) |
272 | return NULL; /* Value wrap, too large new_size. */ | 272 | return NULL; /* Value wrap, too large new_size. */ |
273 | 273 | ||
274 | if (0 != old_size) | 274 | if (0 != old_size) |
@@ -278,7 +278,8 @@ MHD_pool_reallocate (struct MemoryPool *pool, | |||
278 | if (pool->pos == ROUND_TO_ALIGN (old_offset + old_size)) | 278 | if (pool->pos == ROUND_TO_ALIGN (old_offset + old_size)) |
279 | { /* "old" block is the last allocated block */ | 279 | { /* "old" block is the last allocated block */ |
280 | const size_t new_apos = ROUND_TO_ALIGN (old_offset + new_size); | 280 | const size_t new_apos = ROUND_TO_ALIGN (old_offset + new_size); |
281 | if (new_apos > pool->end) | 281 | if ( (new_apos > pool->end) || |
282 | (new_apos < pool->pos) ) /* Value wrap */ | ||
282 | return NULL; /* No space */ | 283 | return NULL; /* No space */ |
283 | 284 | ||
284 | pool->pos = new_apos; | 285 | pool->pos = new_apos; |