From: chunxu.li Date: Mon, 27 Apr 2020 13:27:42 +0000 (+0800) Subject: pcm: Fix memory leak at snd_pcm_new when THREAD_SAVE_API is defined X-Git-Tag: v1.2.3~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=515b336801b3ad1838723e2084683f09eeccfb23;p=alsa-lib.git pcm: Fix memory leak at snd_pcm_new when THREAD_SAVE_API is defined The pthread_mutexattr_t object should be destroyed by calling pthread_mutexattr_destroy(), otherwise it may cause a potential memory leak due to the different implement of pthread_mutexattr_init() Signed-off-by: chunxu.li Signed-off-by: Jaroslav Kysela --- diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index eb8f686d..06a48f4c 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -2763,6 +2763,7 @@ int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name, pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); #endif pthread_mutex_init(&pcm->lock, &attr); + pthread_mutexattr_destroy(&attr); /* use locking as default; * each plugin may suppress this in its open call */