]> granicus.if.org Git - apache/commitdiff
mod_cache: avoid unlikely access to freed memory.
authorYann Ylavic <ylavic@apache.org>
Sat, 18 Oct 2014 08:46:42 +0000 (08:46 +0000)
committerYann Ylavic <ylavic@apache.org>
Sat, 18 Oct 2014 08:46:42 +0000 (08:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1632740 13f79535-47bb-0310-9956-ffa450edef68

modules/cache/mod_cache.c

index 4d6ed20ceb06dc29682cffd1c98a792c19762483..6d909f03d27b25358e897f7e02f4335d2e65fac6 100644 (file)
@@ -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);