Author: ivan
Date: Wed Nov 11 07:20:33 2015
New Revision: 1713769
URL: http://svn.apache.org/viewvc?rev=1713769&view=rev
Log:
Use the same compile-time switch to enable checks for access to destroyed
bucket allocator.
* buckets/allocator.c
(SERF__DEBUG_USE_AFTER_FREE): Remove.
(DEBUG_DOUBLE_FREE): Extend scope of macro.
(allocator_cleanup, serf_bucket_mem_alloc, serf_bucket_mem_free): Replace
'#ifdef SERF__DEBUG_USE_AFTER_FREE' within '#ifdef DEBUG_DOUBLE_FREE'
Modified:
serf/trunk/buckets/allocator.c
Modified: serf/trunk/buckets/allocator.c
URL:
http://svn.apache.org/viewvc/serf/trunk/buckets/allocator.c?rev=1713769&r1=1713768&r2=1713769&view=diff
==============================================================================
--- serf/trunk/buckets/allocator.c (original)
+++ serf/trunk/buckets/allocator.c Wed Nov 11 07:20:33 2015
@@ -35,11 +35,6 @@
* unfreed blocks on pool cleanup. */
/* #define SERF__DEBUG_UNFREED_MEMORY */
-/* Define SERF__DEBUG_USE_AFTER_FREE if you're interested to prevent
- * access bucket allocator after free.
- * TODO: Should we do this by default? */
-/* #define SERF__DEBUG_USE_AFTER_FREE */
-
typedef struct node_header_t {
apr_size_t size;
union {
@@ -79,7 +74,8 @@ typedef struct node_header_t {
#define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE)
/* Define DEBUG_DOUBLE_FREE if you're interested in debugging double-free
- * calls to serf_bucket_mem_free().
+ * calls to serf_bucket_mem_free() and access bucket allocator after it
+ * destroyed.
*/
#define DEBUG_DOUBLE_FREE
@@ -156,7 +152,7 @@ static apr_status_t allocator_cleanup(vo
apr_allocator_destroy(allocator->allocator);
}
-#ifdef SERF__DEBUG_USE_AFTER_FREE
+#ifdef DEBUG_DOUBLE_FREE
/* Set POOL to NULL to detect allocator usage after destroy. */
allocator->pool = NULL;
#endif
@@ -223,7 +219,7 @@ void *serf_bucket_mem_alloc(
node_header_t *node;
void *block;
-#ifdef SERF__DEBUG_USE_AFTER_FREE
+#ifdef DEBUG_DOUBLE_FREE
if (allocator->pool == NULL) {
/* Attempt to use bucket allocator after it destroyed by
* pool cleanup. */
@@ -314,7 +310,7 @@ void serf_bucket_mem_free(
{
node_header_t *node;
-#ifdef SERF__DEBUG_USE_AFTER_FREE
+#ifdef DEBUG_DOUBLE_FREE
if (allocator->pool == NULL) {
/* Attempt to use bucket allocator after it destroyed by
* pool cleanup. */