From edf45934d433d53b2326fd69a45e4cf815e9c018 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Sat, 18 Oct 2014 08:46:42 +0000 Subject: [PATCH] mod_cache: avoid unlikely access to freed memory. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1632740 13f79535-47bb-0310-9956-ffa450edef68 --- modules/cache/mod_cache.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 4d6ed20ceb..6d909f03d2 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -636,7 +636,6 @@ static int cache_handler(request_rec *r) static apr_status_t cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) { request_rec *r = f->r; - apr_bucket *e; cache_request_rec *cache = (cache_request_rec *)f->ctx; if (!cache) { @@ -652,10 +651,8 @@ static apr_status_t cache_out_filter(ap_filter_t *f, apr_bucket_brigade *in) "cache: running CACHE_OUT filter"); /* clean out any previous response up to EOS, if any */ - for (e = APR_BRIGADE_FIRST(in); - e != APR_BRIGADE_SENTINEL(in); - e = APR_BUCKET_NEXT(e)) - { + while (!APR_BRIGADE_EMPTY(in)) { + apr_bucket *e = APR_BRIGADE_FIRST(in); if (APR_BUCKET_IS_EOS(e)) { apr_bucket_brigade *bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); -- 2.40.0