[vlc-commits] Fix mixer leak (and crash at exit) when audio output fails

Rémi Denis-Courmont git at videolan.org
Wed Mar 7 18:16:36 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar  7 19:07:57 2012 +0200| [4f292d82afc5c069855572f0d00919edfb394cf8] | committer: Rémi Denis-Courmont

Fix mixer leak (and crash at exit) when audio output fails

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f292d82afc5c069855572f0d00919edfb394cf8
---

 src/audio_output/dec.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 36749b0..156186a 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -97,7 +97,7 @@ int aout_DecNew( audio_output_t *p_aout,
         aout_Shutdown (p_aout);
     }
 #endif
-    int ret = -1;
+    int ret = 0;
 
     /* TODO: reduce lock scope depending on decoder's real need */
     aout_lock( p_aout );
@@ -110,7 +110,10 @@ int aout_DecNew( audio_output_t *p_aout,
     owner->input_format = *p_format;
     vlc_atomic_set (&owner->restart, 0);
     if( aout_OutputNew( p_aout, p_format ) < 0 )
+    {
+        ret = -1;
         goto error;
+    }
 
     /* Allocate a software mixer */
     assert (owner->volume.mixer == NULL);
@@ -129,9 +132,15 @@ int aout_DecNew( audio_output_t *p_aout,
     owner->input = aout_InputNew (p_aout, p_format, &owner->mixer_format,
                                   p_request_vout);
     if (owner->input == NULL)
+    {
+        struct audio_mixer *mixer = owner->volume.mixer;
+
+        owner->volume.mixer = NULL;
         aout_OutputDelete (p_aout);
-    else
-        ret = 0;
+        aout_unlock (p_aout);
+        aout_MixerDelete (mixer);
+        return -1;
+    }
 error:
     aout_unlock( p_aout );
     return ret;



More information about the vlc-commits mailing list