Blame SOURCES/mod_fcgid-2.3.9-segfault-upload.patch

8cb1ff
diff --git a/modules/fcgid/fcgid_proc_unix.c b/modules/fcgid/fcgid_proc_unix.c
8cb1ff
index 218f3f7..8b69a89 100644
8cb1ff
--- a/modules/fcgid/fcgid_proc_unix.c
8cb1ff
+++ b/modules/fcgid/fcgid_proc_unix.c
8cb1ff
@@ -762,14 +762,15 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
8cb1ff
     struct iovec vec[FCGID_VEC_COUNT];
8cb1ff
     int nvec = 0;
8cb1ff
     apr_bucket *e;
8cb1ff
+    apr_bucket_brigade* tmpbb = apr_brigade_create(output_brigade->p,output_brigade->bucket_alloc);
8cb1ff
 
8cb1ff
-    for (e = APR_BRIGADE_FIRST(output_brigade);
8cb1ff
-         e != APR_BRIGADE_SENTINEL(output_brigade);
8cb1ff
-         e = APR_BUCKET_NEXT(e)) {
8cb1ff
+    while (!APR_BRIGADE_EMPTY(output_brigade)) {
8cb1ff
+        e = APR_BRIGADE_FIRST(output_brigade);
8cb1ff
         apr_size_t len;
8cb1ff
         const char* base;
8cb1ff
 
8cb1ff
         if (APR_BUCKET_IS_METADATA(e)) {
8cb1ff
+            apr_bucket_delete(e);
8cb1ff
             continue;
8cb1ff
         }
8cb1ff
 
8cb1ff
@@ -780,6 +781,9 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
8cb1ff
             return rv;
8cb1ff
         }
8cb1ff
 
8cb1ff
+        APR_BUCKET_REMOVE(e);
8cb1ff
+        APR_BRIGADE_INSERT_TAIL(tmpbb, e);
8cb1ff
+
8cb1ff
         vec[nvec].iov_len = len;
8cb1ff
         vec[nvec].iov_base = (char*) base;
8cb1ff
         if (nvec == (FCGID_VEC_COUNT - 1)) {
8cb1ff
@@ -789,6 +793,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
8cb1ff
                                FCGID_VEC_COUNT)) != APR_SUCCESS)
8cb1ff
                 return rv;
8cb1ff
             nvec = 0;
8cb1ff
+            apr_brigade_cleanup(tmpbb);
8cb1ff
         }
8cb1ff
         else
8cb1ff
             nvec++;
8cb1ff
@@ -800,6 +805,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
8cb1ff
             return rv;
8cb1ff
     }
8cb1ff
 
8cb1ff
+    apr_brigade_destroy(tmpbb);
8cb1ff
     return APR_SUCCESS;
8cb1ff
 }
8cb1ff