diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-09 13:27:25 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-09 13:27:25 +0000 |
commit | 4b9dc01ddb8a0137b9de99ee9ba56a698aafacbb (patch) | |
tree | 782bf2f716086bb1f7b8c8f28923092f9ae6f318 /memory/unix/apr_pools.c | |
parent | 081068fcfd3359f17f31a874513c40a4dbc3b5df (diff) | |
parent | 6490925d4609b9239f7ba6beb91f3bc91a6a2143 (diff) | |
download | libapr-0.9.19.tar.gz |
Tag 0.9.190.9.19
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/tags/0.9.19@1006155 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory/unix/apr_pools.c')
-rw-r--r-- | memory/unix/apr_pools.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 105b44cb1..be371ad7a 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -189,15 +189,19 @@ APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, } static APR_INLINE -apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) +apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size) { apr_memnode_t *node, **ref; apr_uint32_t i, index, max_index; + apr_size_t size; /* Round up the block size to the next boundary, but always * allocate at least a certain size (MIN_ALLOC). */ - size = APR_ALIGN(size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE); + size = APR_ALIGN(in_size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE); + if (size < in_size) { + return NULL; + } if (size < MIN_ALLOC) size = MIN_ALLOC; @@ -625,13 +629,19 @@ void netware_pool_proc_cleanup () * Memory allocation */ -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) +APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t in_size) { apr_memnode_t *active, *node; void *mem; apr_uint32_t free_index; + apr_size_t size; - size = APR_ALIGN_DEFAULT(size); + size = APR_ALIGN_DEFAULT(in_size); + if (size < in_size) { + if (pool->abort_fn) + pool->abort_fn(APR_ENOMEM); + return NULL; + } active = pool->active; /* If the active node has enough bytes left, use it. */ @@ -696,7 +706,6 @@ APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) { void *mem; - size = APR_ALIGN_DEFAULT(size); if ((mem = apr_palloc(pool, size)) != NULL) { memset(mem, 0, size); } |