diff options
author | Joe Orton <jorton@apache.org> | 2020-03-11 17:30:51 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2020-03-11 17:30:51 +0000 |
commit | 4ee00fc9638278554b3791c379ce66f2bc709346 (patch) | |
tree | 55c1c18c05f5dd49a9e8d5ab362c704c80116cd5 /buckets | |
parent | cdcc44488c0ffb2f5d1019165e57eba049aca594 (diff) | |
download | apr-4ee00fc9638278554b3791c379ce66f2bc709346.tar.gz |
* buckets/apr_brigade.c (apr_brigade_cleanup): Non-debug builds should
not check for brigade memory corruption; debug builds should abort
rather than fail silently (since all callers ignore the rv) if
corruption is detected.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1875098 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'buckets')
-rw-r--r-- | buckets/apr_brigade.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/buckets/apr_brigade.c b/buckets/apr_brigade.c index 42403f4a1..c81d29a6c 100644 --- a/buckets/apr_brigade.c +++ b/buckets/apr_brigade.c @@ -37,6 +37,14 @@ static apr_status_t brigade_cleanup(void *data) APR_DECLARE(apr_status_t) apr_brigade_cleanup(void *data) { apr_bucket_brigade *b = data; + +#ifndef APR_BUCKET_DEBUG + while (!APR_BRIGADE_EMPTY(b)) { + apr_bucket_delete(APR_BRIGADE_FIRST(b)); + } +#else + /* Debugging version with checks which will only trigger if the + * bucket list becomes corrupt. */ apr_bucket *e; apr_bucket *prev = NULL; @@ -44,12 +52,12 @@ APR_DECLARE(apr_status_t) apr_brigade_cleanup(void *data) while (!APR_BRIGADE_EMPTY(b)) { e = APR_BRIGADE_FIRST(b); - if (e == prev) { /* PR#51062: prevent infinite loop on a corrupt brigade */ - return APR_EGENERAL; /* FIXME: this should definitely be a "can't happen"! */ - } + assert(e != prev); prev = e; apr_bucket_delete(e); } +#endif + /* We don't need to free(bb) because it's allocated from a pool. */ return APR_SUCCESS; } |