From ecbb4b4ef4ac91f4d79e537ea07492634f50037d Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Mon, 15 Aug 2011 09:51:37 +0800 Subject: [PATCH] memblock: fix memory leak when pa_shm_create_rw fails Signed-off-by: Lu Guanqun --- src/pulsecore/memblock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index e34a739..19be151 100644 --- a/src/pulsecore/memblock.c +++ b/src/pulsecore/memblock.c @@ -711,9 +711,6 @@ pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) { p = pa_xnew(pa_mempool, 1); - p->mutex = pa_mutex_new(TRUE, TRUE); - p->semaphore = pa_semaphore_new(0); - p->block_size = PA_PAGE_ALIGN(PA_MEMPOOL_SLOT_SIZE); if (p->block_size < PA_PAGE_SIZE) p->block_size = PA_PAGE_SIZE; @@ -745,6 +742,9 @@ pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) { PA_LLIST_HEAD_INIT(pa_memimport, p->imports); PA_LLIST_HEAD_INIT(pa_memexport, p->exports); + p->mutex = pa_mutex_new(TRUE, TRUE); + p->semaphore = pa_semaphore_new(0); + p->free_slots = pa_flist_new(p->n_blocks); return p; -- 2.7.4