You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rp...@apache.org on 2022/03/09 07:41:40 UTC

svn commit: r1898772 - in /httpd/httpd/branches/2.4.x: ./ modules/filters/mod_sed.c

Author: rpluem
Date: Wed Mar  9 07:41:40 2022
New Revision: 1898772

URL: http://svn.apache.org/viewvc?rev=1898772&view=rev
Log:
Merge r1898735 from trunk:

* Improve the logic flow

Reviewed by: rpluem, covener, ylavic

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/modules/filters/mod_sed.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1898735

Modified: httpd/httpd/branches/2.4.x/modules/filters/mod_sed.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/filters/mod_sed.c?rev=1898772&r1=1898771&r2=1898772&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/filters/mod_sed.c (original)
+++ httpd/httpd/branches/2.4.x/modules/filters/mod_sed.c Wed Mar  9 07:41:40 2022
@@ -168,21 +168,29 @@ static apr_status_t sed_write_output(voi
         }
         /* buffer is now full */
         status = append_bucket(ctx, ctx->outbuf, ctx->bufsize);
-        /* old buffer is now used so allocate new buffer */
-        alloc_outbuf(ctx);
-        /* if size is bigger than the allocated buffer directly add to output
-         * brigade */
-        if ((status == APR_SUCCESS) && (sz >= ctx->bufsize)) {
-            char* newbuf = apr_pmemdup(ctx->tpool, buf, sz);
-            status = append_bucket(ctx, newbuf, sz);
-            /* pool might get clear after append_bucket */
-            if (ctx->outbuf == NULL) {
+        if (status == APR_SUCCESS) {
+            /* if size is bigger than the allocated buffer directly add to output
+             * brigade */
+            if (sz >= ctx->bufsize) {
+                char* newbuf = apr_pmemdup(ctx->tpool, buf, sz);
+                status = append_bucket(ctx, newbuf, sz);
+                if (status == APR_SUCCESS) {
+                    /* old buffer is now used so allocate new buffer */
+                    alloc_outbuf(ctx);
+                }
+                else {
+                    clear_ctxpool(ctx);
+                }
+            }
+            else {
+                /* old buffer is now used so allocate new buffer */
                 alloc_outbuf(ctx);
+                memcpy(ctx->curoutbuf, buf, sz);
+                ctx->curoutbuf += sz;
             }
         }
         else {
-            memcpy(ctx->curoutbuf, buf, sz);
-            ctx->curoutbuf += sz;
+            clear_ctxpool(ctx);
         }
     }
     else {