From 852b0c61297fa9729c4d7deb23a2ca3564844dc5 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 20 Jan 2004 12:47:05 +0000 Subject: [PATCH] Adam Tla/lka SHM memory leak fix --- src/pcm/pcm_mmap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index 6d525ebc..ba3e7c2a 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -462,11 +462,16 @@ int snd_pcm_munmap(snd_pcm_t *pcm) if (i->u.shm.area) { snd_shm_area_destroy(i->u.shm.area); i->u.shm.area = NULL; - } else { - err = shmdt(i->addr); - if (err < 0) { - SYSERR("shmdt failed"); - return -errno; + if (pcm->access == SND_PCM_ACCESS_MMAP_INTERLEAVED || + pcm->access == SND_PCM_ACCESS_RW_INTERLEAVED) { + unsigned int c1; + for (c1 = c + 1; c1 < pcm->channels; c1++) { + snd_pcm_channel_info_t *i1 = &pcm->mmap_channels[c1]; + if (i1->u.shm.area) { + snd_shm_area_destroy(i1->u.shm.area); + i1->u.shm.area = NULL; + } + } } } break; -- 2.47.1