From 385765703e43f9c91ff8789ce303cc0822b7c165 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 8 Dec 2017 11:41:56 +0100 Subject: [PATCH] copy: Don't modify fmt_out until success is ensured --- modules/packetizer/copy.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/packetizer/copy.c b/modules/packetizer/copy.c index 7c02cfc94f..2ffa58c185 100644 --- a/modules/packetizer/copy.c +++ b/modules/packetizer/copy.c @@ -90,9 +90,6 @@ static int Open( vlc_object_t *p_this ) p_dec->pf_packetize = Packetize; p_dec->pf_flush = Flush; - /* Create the output format */ - es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in ); - p_dec->p_sys = p_sys = malloc( sizeof(*p_sys) ); if (unlikely(p_sys == NULL)) return VLC_ENOMEM; @@ -108,10 +105,11 @@ static int Open( vlc_object_t *p_this ) break; } + vlc_fourcc_t fcc = p_dec->fmt_out.i_codec; /* Fix the value of the fourcc for audio */ if( p_dec->fmt_in.i_cat == AUDIO_ES ) { - vlc_fourcc_t fcc = vlc_fourcc_GetCodecAudio( p_dec->fmt_in.i_codec, + fcc = vlc_fourcc_GetCodecAudio( p_dec->fmt_in.i_codec, p_dec->fmt_in.audio.i_bitspersample ); if( !fcc ) { @@ -119,9 +117,12 @@ static int Open( vlc_object_t *p_this ) free( p_sys ); return VLC_EGENERIC; } - p_dec->fmt_out.i_codec = fcc; } + /* Create the output format */ + es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in ); + p_dec->fmt_out.i_codec = fcc; + return VLC_SUCCESS; } -- 2.11.4.GIT