summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authorstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2002-08-12 22:02:18 +0000
committerstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2002-08-12 22:02:18 +0000
commit171463f154bc7e931aef5c6e4b40bc51726688b8 (patch)
tree87a12091221e82b9aca0286895dfd98312a356c0 /memory
parentfeff4e60c7f4590fb6aa889789974deebe41e221 (diff)
downloadlibapr-171463f154bc7e931aef5c6e4b40bc51726688b8.tar.gz
Fix pools to play nice with gcc bounds checking.
Submitted by: Blair Zajac <blair@orcaware.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63806 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r--memory/unix/apr_pools.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index d8b6dd4fd..059af143a 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -606,24 +606,21 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size)
{
apr_memnode_t *active, *node;
void *mem;
- char *endp;
apr_uint32_t free_index;
size = APR_ALIGN_DEFAULT(size);
active = pool->active;
/* If the active node has enough bytes left, use it. */
- endp = active->first_avail + size;
- if (endp < active->endp) {
+ if (size < active->endp - active->first_avail) {
mem = active->first_avail;
- active->first_avail = endp;
+ active->first_avail += size;
return mem;
}
node = active->next;
- endp = node->first_avail + size;
- if (endp < node->endp) {
+ if (size < node->endp - node->first_avail) {
*node->ref = node->next;
node->next->ref = node->ref;
}
@@ -634,13 +631,12 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size)
return NULL;
}
- endp = node->first_avail + size;
}
node->free_index = 0;
mem = node->first_avail;
- node->first_avail = endp;
+ node->first_avail += size;
node->ref = active->ref;
*node->ref = node;
@@ -929,7 +925,7 @@ static int psprintf_flush(apr_vformatter_buff_t *vbuff)
size = APR_PSPRINTF_MIN_STRINGSIZE;
node = active->next;
- if (!ps->got_a_new_node && node->first_avail + size < node->endp) {
+ if (!ps->got_a_new_node && size < node->endp - node->first_avail) {
*node->ref = node->next;
node->next->ref = node->ref;