[vlc-commits] demux: ts: fix potential leaks with desc/langs
Francois Cartegnie
git at videolan.org
Wed Feb 7 18:05:36 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Feb 7 17:46:23 2018 +0100| [44745880de8554e29fac06592e1ca85642789840] | committer: Francois Cartegnie
demux: ts: fix potential leaks with desc/langs
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=44745880de8554e29fac06592e1ca85642789840
---
modules/demux/mpeg/ts_psi.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index 9100f829b4..fec7120175 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -481,19 +481,26 @@ static void SetupISO639Descriptor( demux_t *p_demux, ts_es_t *p_es,
return;
}
- p_es->fmt.psz_language = malloc( 4 );
- if( p_es->fmt.psz_language )
+ if( !p_es->fmt.psz_language )
{
- memcpy( p_es->fmt.psz_language, p_decoded->code[0].iso_639_code, 3 );
- p_es->fmt.psz_language[3] = 0;
- msg_Dbg( p_demux, " found language: %s", p_es->fmt.psz_language);
+ p_es->fmt.psz_language = malloc( 4 );
+ if( p_es->fmt.psz_language )
+ {
+ memcpy( p_es->fmt.psz_language, p_decoded->code[0].iso_639_code, 3 );
+ p_es->fmt.psz_language[3] = 0;
+ msg_Dbg( p_demux, " found language: %s", p_es->fmt.psz_language);
+ }
}
uint8_t type = p_decoded->code[0].i_audio_type;
- p_es->fmt.psz_description = GetIso639AudioTypeDesc( type );
+ if( !p_es->fmt.psz_description )
+ p_es->fmt.psz_description = GetIso639AudioTypeDesc( type );
if (type == 0x00) /* Undefined */
p_es->fmt.i_priority = ES_PRIORITY_SELECTABLE_MIN + 1; // prioritize normal audio tracks
+ if( p_es->fmt.p_extra_languages )
+ return;
+
p_es->fmt.i_extra_languages = p_decoded->i_code_count-1;
if( p_es->fmt.i_extra_languages > 0 )
p_es->fmt.p_extra_languages =
@@ -1817,7 +1824,8 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
{
msg_Dbg( p_demux, " => pid %d content is *unknown*",
p_dvbpsies->i_pid );
- p_pes->p_es->fmt.psz_description = strdup( psz_typedesc );
+ if( !p_pes->p_es->fmt.psz_description )
+ p_pes->p_es->fmt.psz_description = strdup( psz_typedesc );
}
else
{
More information about the vlc-commits
mailing list