summaryrefslogtreecommitdiff
path: root/buckets
diff options
context:
space:
mode:
Diffstat (limited to 'buckets')
-rw-r--r--buckets/apr_brigade.c6
-rw-r--r--buckets/apr_buckets_alloc.c21
2 files changed, 27 insertions, 0 deletions
diff --git a/buckets/apr_brigade.c b/buckets/apr_brigade.c
index 388b9ae0..eae58f8d 100644
--- a/buckets/apr_brigade.c
+++ b/buckets/apr_brigade.c
@@ -127,6 +127,10 @@ APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b,
APR_RING_UNSPLICE(e, f, link);
APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link);
}
+
+ APR_BRIGADE_CHECK_CONSISTENCY(a);
+ APR_BRIGADE_CHECK_CONSISTENCY(b);
+
return a;
}
@@ -148,6 +152,8 @@ APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b,
return APR_SUCCESS;
}
+ APR_BRIGADE_CHECK_CONSISTENCY(b);
+
APR_BRIGADE_FOREACH(e, b) {
if ((e->length == (apr_size_t)(-1)) && (point > (apr_size_t)(-1))) {
/* XXX: point is too far out to simply split this bucket,
diff --git a/buckets/apr_buckets_alloc.c b/buckets/apr_buckets_alloc.c
index ccad531e..884b5347 100644
--- a/buckets/apr_buckets_alloc.c
+++ b/buckets/apr_buckets_alloc.c
@@ -151,12 +151,33 @@ APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size,
return ((char *)node) + SIZEOF_NODE_HEADER_T;
}
+#ifdef APR_BUCKET_DEBUG
+#if APR_HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+static void check_not_already_free(node_header_t *node)
+{
+ apr_bucket_alloc_t *list = node->alloc;
+ node_header_t *curr = list->freelist;
+
+ while (curr) {
+ if (node == curr) {
+ abort();
+ }
+ curr = curr->next;
+ }
+}
+#else
+#define check_not_already_free(node)
+#endif
+
APU_DECLARE_NONSTD(void) apr_bucket_free(void *mem)
{
node_header_t *node = (node_header_t *)((char *)mem - SIZEOF_NODE_HEADER_T);
apr_bucket_alloc_t *list = node->alloc;
if (node->size == SMALL_NODE_SIZE) {
+ check_not_already_free(node);
node->next = list->freelist;
list->freelist = node;
}