]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core_input_filter: BRIGADE_NORMALIZE() can be called with an empty brigade.
authorYann Ylavic <ylavic@apache.org>
Mon, 14 Dec 2020 17:53:48 +0000 (17:53 +0000)
committerYann Ylavic <ylavic@apache.org>
Mon, 14 Dec 2020 17:53:48 +0000 (17:53 +0000)
So make it a noop in this case, without dereferencing the sentinel (i.e.
change its do{}while to a while{}).

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

server/core_filters.c

index 1b5317888d4ccc5f9967b09336b131fe83a67110..4ea56495e59a09cce11865a1ddf65af740123e60 100644 (file)
 #define BRIGADE_NORMALIZE(b) \
 do { \
     apr_bucket *e = APR_BRIGADE_FIRST(b); \
-    do {  \
+    while (e != APR_BRIGADE_SENTINEL(b)) { \
+        apr_bucket *next = APR_BUCKET_NEXT(e); \
         if (e->length == 0 && !APR_BUCKET_IS_METADATA(e)) { \
-            apr_bucket *d; \
-            d = APR_BUCKET_NEXT(e); \
             apr_bucket_delete(e); \
-            e = d; \
         } \
-        else { \
-            e = APR_BUCKET_NEXT(e); \
-        } \
-    } while (!APR_BRIGADE_EMPTY(b) && (e != APR_BRIGADE_SENTINEL(b))); \
+        e = next; \
+    } \
 } while (0)
 
 /* we know core's module_index is 0 */
@@ -127,9 +123,6 @@ apr_status_t ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
     }
     else {
         ap_filter_reinstate_brigade(f, ctx->bb, NULL);
-        if (APR_BRIGADE_EMPTY(ctx->bb)) {
-            return APR_EOF;
-        }
     }
 
     /* ### This is bad. */