diff options
author | Sander Striker <striker@apache.org> | 2002-08-12 22:02:18 +0000 |
---|---|---|
committer | Sander Striker <striker@apache.org> | 2002-08-12 22:02:18 +0000 |
commit | 1e3e4de2744fa5297e4920a22071442e061fd9b2 (patch) | |
tree | 87a12091221e82b9aca0286895dfd98312a356c0 /memory | |
parent | f8f6e3232af81048ce47a6c8dc6dfabd30e33477 (diff) | |
download | apr-1e3e4de2744fa5297e4920a22071442e061fd9b2.tar.gz |
Fix pools to play nice with gcc bounds checking.
Submitted by: Blair Zajac <blair@orcaware.com>
git-svn-id: https://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.c | 14 |
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; |