[vlc-commits] aout: fix error handling when output creation fails

Rémi Denis-Courmont git at videolan.org
Thu Aug 4 17:16:40 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug  4 15:44:15 2011 +0300| [70e32d82dc98e813b440479a6601a9bf4ea64b3e] | committer: Rémi Denis-Courmont

aout: fix error handling when output creation fails

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

 src/audio_output/dec.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 0f259eb..cd09fac 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -95,30 +95,30 @@ aout_input_t *aout_DecNew( audio_output_t *p_aout,
     aout_owner_t *owner = aout_owner(p_aout);
     aout_lock( p_aout );
     assert (owner->input == NULL);
-    owner->input = p_input;
 
     var_Destroy( p_aout, "audio-device" );
     var_Destroy( p_aout, "audio-channels" );
 
     /* Recreate the output using the new format. */
     if( aout_OutputNew( p_aout, p_format ) < 0 )
-#warning Input without output and mixer = bad idea.
-        goto out;
+        goto error;
 
     assert (owner->volume.mixer == NULL);
     owner->volume.mixer = aout_MixerNew (p_aout, owner->mixer_format.i_format);
     if (owner->volume.mixer == NULL)
     {
         aout_OutputDelete( p_aout );
-#warning Memory leak.
-        p_input = NULL;
-        goto out;
+        goto error;
     }
 
+    owner->input = p_input;
     aout_InputNew( p_aout, p_input, p_request_vout );
-out:
     aout_unlock( p_aout );
     return p_input;
+error:
+    aout_unlock( p_aout );
+    free( p_input );
+    return NULL;
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list