Good catch! An alternative solution (and IMHO better one) would be to move the two lines allocating the mutex and semaphore below the if-block that can return. That way you avoid the memory-leak situation alltogether.
Maarten 2011/8/15 Lu Guanqun <[email protected]>: > Signed-off-by: Lu Guanqun <[email protected]> > --- > src/pulsecore/memblock.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c > index e34a739..332fcb7 100644 > --- a/src/pulsecore/memblock.c > +++ b/src/pulsecore/memblock.c > @@ -728,6 +728,8 @@ pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) > { > } > > if (pa_shm_create_rw(&p->memory, p->n_blocks * p->block_size, shared, > 0700) < 0) { > + pa_semaphore_free(p->semaphore); > + pa_mutex_free(p->mutex); > pa_xfree(p); > return NULL; > } > > _______________________________________________ > pulseaudio-discuss mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss > _______________________________________________ pulseaudio-discuss mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
