Commit 52ca31e6 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Check memory allocations.

parent 69afa855
...@@ -124,6 +124,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force ) ...@@ -124,6 +124,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
p_demux->pf_demux = Demux; p_demux->pf_demux = Demux;
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( !p_sys ) return VLC_ENOMEM;
/* Init p_sys */ /* Init p_sys */
p_sys->i_mux_rate = 0; p_sys->i_mux_rate = 0;
...@@ -559,6 +560,7 @@ static block_t *ps_pkt_read( stream_t *s, uint32_t i_code ) ...@@ -559,6 +560,7 @@ static block_t *ps_pkt_read( stream_t *s, uint32_t i_code )
const uint8_t *p_peek; const uint8_t *p_peek;
int i_peek = stream_Peek( s, &p_peek, 14 ); int i_peek = stream_Peek( s, &p_peek, 14 );
int i_size = ps_pkt_size( p_peek, i_peek ); int i_size = ps_pkt_size( p_peek, i_peek );
VLC_UNUSED(i_code);
if( i_size <= 6 && p_peek[3] > 0xba ) if( i_size <= 6 && p_peek[3] > 0xba )
{ {
......
...@@ -168,8 +168,11 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm, int i_id ) ...@@ -168,8 +168,11 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm, int i_id )
if( ps_id_to_lang( p_psm, i_id ) ) if( ps_id_to_lang( p_psm, i_id ) )
{ {
tk->fmt.psz_language = malloc( 4 ); tk->fmt.psz_language = malloc( 4 );
memcpy( tk->fmt.psz_language, ps_id_to_lang( p_psm , i_id ), 3 ); if( tk->fmt.psz_language )
tk->fmt.psz_language[3] = 0; {
memcpy( tk->fmt.psz_language, ps_id_to_lang( p_psm , i_id ), 3 );
tk->fmt.psz_language[3] = 0;
}
} }
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -534,6 +537,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt, ...@@ -534,6 +537,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
while( i_es_base + 4 < i_length ) while( i_es_base + 4 < i_length )
{ {
ps_es_t **tmp_es;
ps_es_t es; ps_es_t es;
es.lang[0] = es.lang[1] = es.lang[2] = 0; es.lang[0] = es.lang[1] = es.lang[2] = 0;
...@@ -556,31 +560,41 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt, ...@@ -556,31 +560,41 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
int i = 0; int i = 0;
es.p_descriptor = malloc( i_info_length ); es.p_descriptor = malloc( i_info_length );
memcpy( es.p_descriptor, p_buffer + i_es_base + 4, i_info_length); if( es.p_descriptor )
while( i <= es.i_descriptor - 2 )
{ {
/* Look for the ISO639 language descriptor */ memcpy( es.p_descriptor, p_buffer + i_es_base + 4, i_info_length);
if( es.p_descriptor[i] != 0x0a )
{
i += es.p_descriptor[i+1] + 2;
continue;
}
if( i <= es.i_descriptor - 6 ) while( i <= es.i_descriptor - 2 )
{ {
es.lang[0] = es.p_descriptor[i+2]; /* Look for the ISO639 language descriptor */
es.lang[1] = es.p_descriptor[i+3]; if( es.p_descriptor[i] != 0x0a )
es.lang[2] = es.p_descriptor[i+4]; {
i += es.p_descriptor[i+1] + 2;
continue;
}
if( i <= es.i_descriptor - 6 )
{
es.lang[0] = es.p_descriptor[i+2];
es.lang[1] = es.p_descriptor[i+3];
es.lang[2] = es.p_descriptor[i+4];
}
break;
} }
break;
} }
} }
p_psm->es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) ); tmp_es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
p_psm->es[p_psm->i_es] = malloc( sizeof(ps_es_t) ); if( tmp_es )
*p_psm->es[p_psm->i_es++] = es; {
i_es_base += 4 + i_info_length; p_psm->es = tmp_es;
p_psm->es[p_psm->i_es] = malloc( sizeof(ps_es_t) );
if( p_psm->es[p_psm->i_es] )
{
*p_psm->es[p_psm->i_es++] = es;
i_es_base += 4 + i_info_length;
}
}
} }
/* TODO: CRC */ /* TODO: CRC */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment