From: Lennart Poettering Date: Mon, 6 Aug 2007 17:37:59 +0000 (+0000) Subject: fix a memory leak X-Git-Tag: 1.0_branch~2762^2~1^2~386 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=455ff8d342a914f29971dfc7b2c48f9cf09c0f1b;p=profile%2Fivi%2Fpulseaudio.git fix a memory leak git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1582 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c index c88f9aa..ea23880 100644 --- a/src/pulsecore/pstream.c +++ b/src/pulsecore/pstream.c @@ -274,7 +274,7 @@ pa_pstream *pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *poo return p; } -static void item_free(void *item, PA_GCC_UNUSED void *p) { +static void item_free(void *item, PA_GCC_UNUSED void *q) { struct item_info *i = item; pa_assert(i); @@ -299,15 +299,15 @@ static void pstream_free(pa_pstream *p) { if (p->write.current) item_free(p->write.current, NULL); + if (p->write.memchunk.memblock) + pa_memblock_unref(p->write.memchunk.memblock); + if (p->read.memblock) pa_memblock_unref(p->read.memblock); if (p->read.packet) pa_packet_unref(p->read.packet); - if (p->write.memchunk.memblock) - pa_memblock_unref(p->write.memchunk.memblock); - pa_xfree(p); } @@ -568,9 +568,14 @@ static int do_write(pa_pstream *p) { if (p->write.index >= PA_PSTREAM_DESCRIPTOR_SIZE + ntohl(p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH])) { pa_assert(p->write.current); - item_free(p->write.current, (void *) 1); + item_free(p->write.current, NULL); p->write.current = NULL; + if (p->write.memchunk.memblock) + pa_memblock_unref(p->write.memchunk.memblock); + + pa_memchunk_reset(&p->write.memchunk); + if (p->drain_callback && !pa_pstream_is_pending(p)) p->drain_callback(p, p->drain_callback_userdata); }