]> granicus.if.org Git - apache/commitdiff
* modules/generators/cgi_common.h (discard_script_output): Simplify
authorJoe Orton <jorton@apache.org>
Fri, 4 Oct 2019 09:24:07 +0000 (09:24 +0000)
committerJoe Orton <jorton@apache.org>
Fri, 4 Oct 2019 09:24:07 +0000 (09:24 +0000)
  slightly and ensure constant rather than unlimited memory
  consumption when discarding CGI script output (for e.g. a redirect
  response).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867970 13f79535-47bb-0310-9956-ffa450edef68

modules/generators/cgi_common.h

index 6b24950e89ee90b97ddc8e45b655a51683c327a2..0ff66f94e3a0cb9e4ccec08767b43b4ba11c61f7 100644 (file)
@@ -32,19 +32,15 @@ static void discard_script_output(apr_bucket_brigade *bb)
     apr_bucket *e;
     const char *buf;
     apr_size_t len;
-    apr_status_t rv;
 
     for (e = APR_BRIGADE_FIRST(bb);
-         e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
+         e != APR_BRIGADE_SENTINEL(bb) && !APR_BUCKET_IS_EOS(e);
+         e = APR_BRIGADE_FIRST(bb))
     {
-        if (APR_BUCKET_IS_EOS(e)) {
-            break;
-        }
-        rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ);
-        if (rv != APR_SUCCESS) {
+        if (apr_bucket_read(e, &buf, &len, APR_BLOCK_READ)) {
             break;
         }
+        apr_bucket_delete(e);
     }
 }