mod_proxy_ftp: NULL pointer dereference on error paths.
[Stefan Fritsch <sf fritsch.de>, Joe Orton]
+ *) core: Fix potential memory leaks by making sure to not destroy
+ bucket brigades that have been created by earlier filters.
+ [Stefan Fritsch]
+
*) core, mod_deflate, mod_sed: Reduce memory usage by reusing bucket
brigades in several places. [Stefan Fritsch]
static void setaside_remaining_output(ap_filter_t *f,
core_output_filter_ctx_t *ctx,
apr_bucket_brigade *bb,
- int make_a_copy, conn_rec *c);
+ conn_rec *c);
static apr_status_t send_brigade_nonblocking(apr_socket_t *s,
apr_bucket_brigade *bb,
}
}
+ if (new_bb != NULL) {
+ bb = new_bb;
+ }
+
if ((ctx->buffered_bb != NULL) &&
!APR_BRIGADE_EMPTY(ctx->buffered_bb)) {
- bb = ctx->buffered_bb;
- ctx->buffered_bb = NULL;
if (new_bb != NULL) {
- APR_BRIGADE_CONCAT(bb, new_bb);
+ APR_BRIGADE_PREPEND(bb, ctx->buffered_bb);
+ }
+ else {
+ bb = ctx->buffered_bb;
}
c->data_in_output_filters = 0;
}
- else if (new_bb != NULL) {
- bb = new_bb;
- }
- else {
+ else if (new_bb == NULL) {
return APR_SUCCESS;
}
/* The client has aborted the connection */
c->aborted = 1;
}
- setaside_remaining_output(f, ctx, bb, 0, c);
+ setaside_remaining_output(f, ctx, bb, c);
return rv;
}
}
}
- setaside_remaining_output(f, ctx, bb, 1, c);
+ setaside_remaining_output(f, ctx, bb, c);
return APR_SUCCESS;
}
static void setaside_remaining_output(ap_filter_t *f,
core_output_filter_ctx_t *ctx,
apr_bucket_brigade *bb,
- int make_a_copy, conn_rec *c)
+ conn_rec *c)
{
if (bb == NULL) {
return;
remove_empty_buckets(bb);
if (!APR_BRIGADE_EMPTY(bb)) {
c->data_in_output_filters = 1;
- if (make_a_copy) {
+ if (bb != ctx->buffered_bb) {
/* XXX should this use a separate deferred write pool, like
* the original ap_core_output_filter?
*/
ap_save_brigade(f, &(ctx->buffered_bb), &bb, c->pool);
- apr_brigade_destroy(bb);
- }
- else {
- ctx->buffered_bb = bb;
+ apr_brigade_cleanup(bb);
}
}
- else {
- apr_brigade_destroy(bb);
- }
}
#ifndef APR_MAX_IOVEC_SIZE