]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: Fix memory leak at snd_pcm_new when THREAD_SAVE_API is defined
authorchunxu.li <chunxuxiao@gmail.com>
Mon, 27 Apr 2020 13:27:42 +0000 (21:27 +0800)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Jun 2020 08:04:18 +0000 (10:04 +0200)
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 <chunxuxiao@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm.c

index eb8f686df5256592e9b9ae5d1ced04eb408a9418..06a48f4c344aaf68622c36ff86542f8fe2843601 100644 (file)
@@ -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
         */