Commit e1066b6e authored by Laurent Aimar's avatar Laurent Aimar

id3tag: fixed segfault (introduced with demux_meta_t)

parent 5c1bbbef
...@@ -65,14 +65,13 @@ static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) ...@@ -65,14 +65,13 @@ static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size )
vlc_meta_t *p_meta; vlc_meta_t *p_meta;
int i; int i;
TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
p_demux_meta->p_meta = NULL;
p_id3_tag = id3_tag_parse( p_data, i_size ); p_id3_tag = id3_tag_parse( p_data, i_size );
if( !p_id3_tag ) if( !p_id3_tag )
return; return;
p_demux_meta->p_meta = p_meta = vlc_meta_New(); if( !p_demux_meta->p_meta )
p_demux_meta->p_meta = vlc_meta_New();
p_meta = p_demux_meta->p_meta;
#define ID_IS( a ) (!strcmp( p_frame->id, a )) #define ID_IS( a ) (!strcmp( p_frame->id, a ))
#define DESCR_IS( a) strstr( (char*)p_frame->description, a ) #define DESCR_IS( a) strstr( (char*)p_frame->description, a )
...@@ -265,7 +264,8 @@ static int GetAPEvXSize( const uint8_t *p_data, int i_data ) ...@@ -265,7 +264,8 @@ static int GetAPEvXSize( const uint8_t *p_data, int i_data )
} }
static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data )
{ {
vlc_meta_t *p_meta = (vlc_meta_t *)p_demux->p_private; demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private;
vlc_meta_t *p_meta;
vlc_bool_t b_start; vlc_bool_t b_start;
vlc_bool_t b_end; vlc_bool_t b_end;
uint8_t *p_header = NULL; uint8_t *p_header = NULL;
...@@ -279,6 +279,10 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) ...@@ -279,6 +279,10 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data )
if( !b_end && !b_start ) if( !b_end && !b_start )
return; return;
if( !p_demux_meta->p_meta )
p_demux_meta->p_meta = vlc_meta_New();
p_meta = p_demux_meta->p_meta;
if( b_start ) if( b_start )
{ {
p_header = &p_data[0]; p_header = &p_data[0];
...@@ -297,9 +301,6 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) ...@@ -297,9 +301,6 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data )
if( i_entry <= 0 ) if( i_entry <= 0 )
return; return;
if( !p_meta )
p_demux->p_private = p_meta = vlc_meta_New();
while( i_entry > 0 && i_data >= 10 ) while( i_entry > 0 && i_data >= 10 )
{ {
const int i_size = GetDWLE( &p_data[0] ); const int i_size = GetDWLE( &p_data[0] );
...@@ -481,18 +482,21 @@ static void CheckHeader( demux_t *p_demux ) ...@@ -481,18 +482,21 @@ static void CheckHeader( demux_t *p_demux )
****************************************************************************/ ****************************************************************************/
static int ParseTags( vlc_object_t *p_this ) static int ParseTags( vlc_object_t *p_this )
{ {
demux_t *p_demux = (demux_t *)p_this; demux_t *p_demux = (demux_t *)p_this;
vlc_bool_t b_seekable; demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private;
int64_t i_init; vlc_bool_t b_seekable;
int64_t i_init;
msg_Dbg( p_demux, "checking for ID3v1/2 and APEv1/2 tags" ); msg_Dbg( p_demux, "checking for ID3v1/2 and APEv1/2 tags" );
stream_Control( p_demux->s, STREAM_CAN_FASTSEEK, &b_seekable ); stream_Control( p_demux->s, STREAM_CAN_FASTSEEK, &b_seekable );
if( !b_seekable ) if( !b_seekable )
return VLC_SUCCESS; return VLC_EGENERIC;
i_init = stream_Tell( p_demux->s ); i_init = stream_Tell( p_demux->s );
TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
p_demux_meta->p_meta = NULL;
/* */ /* */
CheckFooter( p_demux ); CheckFooter( p_demux );
...@@ -504,5 +508,8 @@ static int ParseTags( vlc_object_t *p_this ) ...@@ -504,5 +508,8 @@ static int ParseTags( vlc_object_t *p_this )
* for them * for them
*/ */
stream_Seek( p_demux->s, i_init ); stream_Seek( p_demux->s, i_init );
if( !p_demux_meta->p_meta && p_demux_meta->i_attachments <= 0 )
return VLC_EGENERIC;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -231,7 +231,7 @@ static int ReadMeta( vlc_object_t *p_this ) ...@@ -231,7 +231,7 @@ static int ReadMeta( vlc_object_t *p_this )
{ {
demux_t *p_demux = (demux_t *)p_this; demux_t *p_demux = (demux_t *)p_this;
demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private;
vlc_meta_t *p_meta = p_demux_meta->p_meta; vlc_meta_t *p_meta;
TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
p_demux_meta->p_meta = NULL; p_demux_meta->p_meta = NULL;
......
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