Skip to content

Commit

Permalink
Merge r1867970 from trunk:
Browse files Browse the repository at this point in the history
* modules/generators/cgi_common.h (discard_script_output): Simplify
  slightly and ensure constant rather than unlimited memory
  consumption when discarding CGI script output (for e.g. a redirect
  response).

Submitted by: jorton
  • Loading branch information
notroj committed Apr 5, 2024
1 parent 29bc2e9 commit 1be960f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions modules/generators/cgi_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,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);
}
}

Expand Down

0 comments on commit 1be960f

Please sign in to comment.