mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-05 19:52:14 +00:00
[BUG] fix segfault at exit when using captures
since pools v2, the way pools were destroyed at exit is incorrect because it ought to account for users of those pools before freeing them. This test also ensures there is no double free.
This commit is contained in:
parent
74b98a8c22
commit
dae4aa8c4a
16
src/memory.c
16
src/memory.c
@ -142,15 +142,23 @@ void pool_gc2()
|
||||
}
|
||||
|
||||
/*
|
||||
* This function destroys a pull by freeing it completely.
|
||||
* This should be called only under extreme circumstances.
|
||||
* It always returns NULL, easing the clearing of the old pointer.
|
||||
* This function destroys a pool by freeing it completely, unless it's still
|
||||
* in use. This should be called only under extreme circumstances. It always
|
||||
* returns NULL if the resulting pool is empty, easing the clearing of the old
|
||||
* pointer, otherwise it returns the pool.
|
||||
* .
|
||||
*/
|
||||
void *pool_destroy2(struct pool_head *pool)
|
||||
{
|
||||
if (pool) {
|
||||
pool_flush2(pool);
|
||||
FREE(pool);
|
||||
if (pool->used)
|
||||
return pool;
|
||||
pool->users--;
|
||||
if (!pool->users) {
|
||||
LIST_DEL(&pool->list);
|
||||
FREE(pool);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user