changeset 29343:28486169f9e0

Move allocation to avoid a possible memleak if new_sh_audio fails.
author reimar
date Wed, 24 Jun 2009 08:06:46 +0000
parents ec913e932635
children fb8ad1c8b5d6
files libmpdemux/demux_lavf.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Wed Jun 24 08:04:38 2009 +0000
+++ b/libmpdemux/demux_lavf.c	Wed Jun 24 08:06:46 2009 +0000
@@ -225,7 +225,7 @@
     switch(codec->codec_type){
         case CODEC_TYPE_AUDIO:{
             int override_tag;
-            WAVEFORMATEX *wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
+            WAVEFORMATEX *wf;
             sh_audio_t* sh_audio;
             sh_audio=new_sh_audio(demuxer, i);
             mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "lavf", i);
@@ -233,6 +233,7 @@
                 break;
             priv->astreams[priv->audio_streams] = i;
             priv->audio_streams++;
+            wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
             // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
             override_tag= av_codec_get_tag(mp_wav_override_taglists, codec->codec_id);
             if (override_tag)