diff options
author | sf <sf@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-20 21:48:20 +0000 |
---|---|---|
committer | sf <sf@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-20 21:48:20 +0000 |
commit | b5af24fb42066aa75366cfd12d10ebcdaed1b61f (patch) | |
tree | 2e22be2fec7db70d3fee47573a252380405986f8 /memory/unix | |
parent | 3e1396cecf5127203ea4b1383f33c5a46b71af48 (diff) | |
download | libapr-b5af24fb42066aa75366cfd12d10ebcdaed1b61f.tar.gz |
Backport of r990435:
Fix various off-by-one errors related to current_free_index:
current_free_index counts pages of size BOUNDARY_SIZE, but every node contains
index + 1 of such pages
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1083587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory/unix')
-rw-r--r-- | memory/unix/apr_pools.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 3973055d5..fcc0bf0b2 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -259,7 +259,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size) allocator->max_index = max_index; } - allocator->current_free_index += node->index; + allocator->current_free_index += node->index + 1; if (allocator->current_free_index > allocator->max_free_index) allocator->current_free_index = allocator->max_free_index; @@ -299,7 +299,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size) if (node) { *ref = node->next; - allocator->current_free_index += node->index; + allocator->current_free_index += node->index + 1; if (allocator->current_free_index > allocator->max_free_index) allocator->current_free_index = allocator->max_free_index; @@ -358,7 +358,7 @@ void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) index = node->index; if (max_free_index != APR_ALLOCATOR_MAX_FREE_UNLIMITED - && index > current_free_index) { + && index + 1 > current_free_index) { node->next = freelist; freelist = node; } @@ -371,8 +371,8 @@ void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) max_index = index; } allocator->free[index] = node; - if (current_free_index >= index) - current_free_index -= index; + if (current_free_index >= index + 1) + current_free_index -= index + 1; else current_free_index = 0; } @@ -382,8 +382,8 @@ void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) */ node->next = allocator->free[0]; allocator->free[0] = node; - if (current_free_index >= index) - current_free_index -= index; + if (current_free_index >= index + 1) + current_free_index -= index + 1; else current_free_index = 0; } |