Commit 3587dbd0 authored by Cliff Woolley's avatar Cliff Woolley
Browse files

fix some major badness: error buckets *cannot* use simple_copy because

they're not simple buckets.  they have a private data structure which
gets freed.  if you're going to copy them and share whatever ->data points
to (which is what simple_copy does), you have to refcount the structure,
which is the whole point of apr_bucket_refcount and apr_bucket_shared_copy.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95421 13f79535-47bb-0310-9956-ffa450edef68
parent 6c59a69a
Loading
Loading
Loading
Loading
+2 −0
Changes for include/http_protocol.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -658,6 +658,8 @@ typedef struct ap_bucket_error ap_bucket_error;
 * first brigade to be sent from a given filter.
 */
struct ap_bucket_error {
    /** Number of buckets using this memory */
    apr_bucket_refcount refcount;
    /** The error code */
    int status;
    /** The error string */
+12 −5
Changes for server/error_bucket.c: 12 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -67,6 +67,15 @@ static apr_status_t error_bucket_read(apr_bucket *b, const char **str,
    return APR_SUCCESS;
}

static void error_bucket_destroy(void *data)
{
    ap_bucket_error *h = data;

    if (apr_bucket_shared_destroy(h)) {
        apr_bucket_free(h);
    }
}

AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
                                              const char *buf, apr_pool_t *p)
{
@@ -76,10 +85,8 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
    h->status = error;
    h->data = (buf) ? apr_pstrdup(p, buf) : NULL;

    b->length = 0;
    b->start  = 0;
    b = apr_bucket_shared_make(b, h, 0, 0);
    b->type = &ap_bucket_type_error;
    b->data = h;
    return b;
}

@@ -97,9 +104,9 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,

AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = {
    "ERROR", 5,
    apr_bucket_free,
    error_bucket_destroy,
    error_bucket_read,
    apr_bucket_setaside_notimpl,
    apr_bucket_split_notimpl,
    apr_bucket_simple_copy
    apr_bucket_shared_copy
};