[dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.34,
1.35 mempool-datastack.c, 1.11, 1.12 mempool-system.c, 1.17,
1.18 mempool-unsafe-datastack.c, 1.2, 1.3 mempool.h, 1.17, 1.18
cras at dovecot.org
cras at dovecot.org
Sat Jan 14 19:23:24 EET 2006
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv16329
Modified Files:
mempool-alloconly.c mempool-datastack.c mempool-system.c
mempool-unsafe-datastack.c mempool.h
Log Message:
pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
twice we'll do a clean crash.
Index: mempool-alloconly.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-alloconly.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- mempool-alloconly.c 13 Jan 2006 20:26:01 -0000 1.34
+++ mempool-alloconly.c 14 Jan 2006 17:23:22 -0000 1.35
@@ -41,7 +41,7 @@
static const char *pool_alloconly_get_name(pool_t pool);
static void pool_alloconly_ref(pool_t pool);
-static void pool_alloconly_unref(pool_t pool);
+static void pool_alloconly_unref(pool_t *pool);
static void *pool_alloconly_malloc(pool_t pool, size_t size);
static void pool_alloconly_free(pool_t pool, void *mem);
static void *pool_alloconly_realloc(pool_t pool, void *mem,
@@ -137,9 +137,13 @@
apool->refcount++;
}
-static void pool_alloconly_unref(pool_t pool)
+static void pool_alloconly_unref(pool_t *pool)
{
- struct alloconly_pool *apool = (struct alloconly_pool *) pool;
+ struct alloconly_pool *apool = (struct alloconly_pool *)*pool;
+
+ /* erase the pointer before freeing anything, as the pointer may
+ exist inside the pool's memory area */
+ *pool = NULL;
if (--apool->refcount == 0)
pool_alloconly_destroy(apool);
Index: mempool-datastack.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-datastack.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mempool-datastack.c 27 Mar 2005 13:29:30 -0000 1.11
+++ mempool-datastack.c 14 Jan 2006 17:23:22 -0000 1.12
@@ -7,7 +7,7 @@
static const char *pool_data_stack_get_name(pool_t pool);
static void pool_data_stack_ref(pool_t pool);
-static void pool_data_stack_unref(pool_t pool);
+static void pool_data_stack_unref(pool_t *pool);
static void *pool_data_stack_malloc(pool_t pool, size_t size);
static void pool_data_stack_free(pool_t pool, void *mem);
static void *pool_data_stack_realloc(pool_t pool, void *mem,
@@ -66,15 +66,17 @@
dpool->refcount++;
}
-static void pool_data_stack_unref(pool_t pool)
+static void pool_data_stack_unref(pool_t *pool)
{
- struct datastack_pool *dpool = (struct datastack_pool *) pool;
+ struct datastack_pool *dpool = (struct datastack_pool *)*pool;
if (dpool->data_stack_frame != data_stack_frame)
i_panic("pool_data_stack_unref(): stack frame changed");
dpool->refcount--;
i_assert(dpool->refcount >= 0);
+
+ *pool = NULL;
}
static void *pool_data_stack_malloc(pool_t pool __attr_unused__, size_t size)
Index: mempool-system.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-system.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mempool-system.c 27 Mar 2005 13:29:30 -0000 1.17
+++ mempool-system.c 14 Jan 2006 17:23:22 -0000 1.18
@@ -15,7 +15,7 @@
static const char *pool_system_get_name(pool_t pool);
static void pool_system_ref(pool_t pool);
-static void pool_system_unref(pool_t pool);
+static void pool_system_unref(pool_t *pool);
static void *pool_system_malloc(pool_t pool, size_t size);
static void pool_system_free(pool_t pool, void *mem);
static void *pool_system_realloc(pool_t pool, void *mem,
@@ -52,7 +52,7 @@
{
}
-static void pool_system_unref(pool_t pool __attr_unused__)
+static void pool_system_unref(pool_t *pool __attr_unused__)
{
}
Index: mempool-unsafe-datastack.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-unsafe-datastack.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mempool-unsafe-datastack.c 27 Mar 2005 13:29:30 -0000 1.2
+++ mempool-unsafe-datastack.c 14 Jan 2006 17:23:22 -0000 1.3
@@ -7,7 +7,7 @@
static const char *pool_unsafe_data_stack_get_name(pool_t pool);
static void pool_unsafe_data_stack_ref(pool_t pool);
-static void pool_unsafe_data_stack_unref(pool_t pool);
+static void pool_unsafe_data_stack_unref(pool_t *pool);
static void *pool_unsafe_data_stack_malloc(pool_t pool, size_t size);
static void pool_unsafe_data_stack_free(pool_t pool, void *mem);
static void *pool_unsafe_data_stack_realloc(pool_t pool, void *mem,
@@ -44,7 +44,7 @@
{
}
-static void pool_unsafe_data_stack_unref(pool_t pool __attr_unused__)
+static void pool_unsafe_data_stack_unref(pool_t *pool __attr_unused__)
{
}
Index: mempool.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mempool.h 27 Mar 2005 13:51:54 -0000 1.17
+++ mempool.h 14 Jan 2006 17:23:22 -0000 1.18
@@ -13,7 +13,7 @@
const char *(*get_name)(pool_t pool);
void (*ref)(pool_t pool);
- void (*unref)(pool_t pool);
+ void (*unref)(pool_t *pool);
void *(*malloc)(pool_t pool, size_t size);
void (*free)(pool_t pool, void *mem);
@@ -58,7 +58,7 @@
/* Pools should be used through these macros: */
#define pool_get_name(pool) (pool)->get_name(pool)
#define pool_ref(pool) (pool)->ref(pool)
-#define pool_unref(pool) (pool)->unref(pool)
+#define pool_unref(pool) (pool)->unref(&(pool))
#define p_new(pool, type, count) \
((type *) p_malloc(pool, sizeof(type) * (count)))
More information about the dovecot-cvs
mailing list