PCM: Fix memory leak for pcm empty and asym plugins
authorJaroslav Kysela <perex@perex.cz>
Tue, 30 Oct 2012 10:43:07 +0000 (11:43 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 30 Oct 2012 10:43:07 +0000 (11:43 +0100)
The init-only plugins do not have own pcm handle, so free the references
to open function immediately after open.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

src/pcm/pcm.c

index 5880057..359d295 100644 (file)
@@ -2171,7 +2171,12 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
        if (open_func) {
                err = open_func(pcmp, name, pcm_root, pcm_conf, stream, mode);
                if (err >= 0) {
-                       (*pcmp)->open_func = open_func;
+                       if ((*pcmp)->open_func) {
+                               /* only init plugin (like empty, asym) */
+                               snd_dlobj_cache_put(open_func);
+                       } else {
+                               (*pcmp)->open_func = open_func;
+                       }
                        err = 0;
                } else {
                        snd_dlobj_cache_put(open_func);