diff options
author | Joe Orton <jorton@apache.org> | 2010-06-05 20:43:15 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2010-06-05 20:43:15 +0000 |
commit | 52cd520bb5902319edc552c2a1185cc50091d704 (patch) | |
tree | 119726a0796e2eea79ed36735e0e1b20a346be3e /buckets | |
parent | 2eecee3d1cbbee9964002a24a45913900906c03d (diff) | |
download | apr-52cd520bb5902319edc552c2a1185cc50091d704.tar.gz |
Add debugging traps for use-after-destroy of a brigade:
* buckets/apr_brigade.c (apr_brigade_cleanup): Check brigade
consistency.
(apr_brigade_destroy) [APR_BUCKET_DEBUG]: Check brigade consistency
before destroying it, and clear b->p, b->bucket_alloc after.
* include/apr_buckets.h (APR_BRIGADE_CHECK_CONSISTENCY): assert that
b->p and b->bucket_alloc are non-NULL.
Suggested by: sf
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@951762 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'buckets')
-rw-r--r-- | buckets/apr_brigade.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/buckets/apr_brigade.c b/buckets/apr_brigade.c index 4519f6419..2b5893077 100644 --- a/buckets/apr_brigade.c +++ b/buckets/apr_brigade.c @@ -39,6 +39,8 @@ APR_DECLARE(apr_status_t) apr_brigade_cleanup(void *data) apr_bucket_brigade *b = data; apr_bucket *e; + APR_BRIGADE_CHECK_CONSISTENCY(b); + while (!APR_BRIGADE_EMPTY(b)) { e = APR_BRIGADE_FIRST(b); apr_bucket_delete(e); @@ -49,8 +51,22 @@ APR_DECLARE(apr_status_t) apr_brigade_cleanup(void *data) APR_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b) { - apr_pool_cleanup_kill(b->p, b, brigade_cleanup); - return apr_brigade_cleanup(b); +#ifndef APR_BUCKET_DEBUG + return apr_pool_cleanup_run(b->p, b, brigade_cleanup); +#else + apr_status_t rv; + + APR_BRIGADE_CHECK_CONSISTENCY(b); + + rv = apr_pool_cleanup_run(b->p, b, brigade_cleanup); + + /* Trigger consistency check failures if the brigade is + * re-used. */ + b->p = NULL; + b->bucket_alloc = NULL; + + return rv; +#endif } APR_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p, |