Commit d0cc3145 authored by zorglub's avatar zorglub
Browse files

sap: don't crash on invalid o= field

wx: really commit last commit
parent 3a9b48da
......@@ -493,6 +493,8 @@ void Playlist::CreateNode( playlist_t *p_playlist, playlist_item_t *p_node,
wxL2U( p_node->pp_children[i]->input.psz_name ), -1,-1,
new PlaylistItem( p_node->pp_children[i]) );
UpdateTreeItem( p_playlist, item );
treectrl->SetItemImage( item,
p_node->pp_children[i]->input.i_type );
}
......@@ -593,22 +595,18 @@ void Playlist::UpdateItem( int i )
wxTreeItemId item = FindItem( treectrl->GetRootItem(), p_item);
UpdateTreeItem( p_playlist, item );
if( item.IsOk() )
{
UpdateTreeItem( p_playlist, item );
}
vlc_object_release(p_playlist);
}
void Playlist::UpdateTreeItem( playlist_t *p_playlist ,wxTreeItemId item )
{
playlist_item_t *p_item;
if( !item.IsOk() )
{
return;
}
p_item = ((PlaylistItem *)treectrl->GetItemData( item ))->p_item;
playlist_item_t *p_item =
((PlaylistItem *)treectrl->GetItemData( item ))->p_item;
if( !p_item )
{
......@@ -617,15 +615,16 @@ void Playlist::UpdateTreeItem( playlist_t *p_playlist ,wxTreeItemId item )
wxString msg;
char *psz_author = playlist_ItemGetInfo( p_item, _("Meta-information"),
_("Artist"));
_("Artist"));
char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = p_item->input.i_duration;
if( dur != -1 )
secstotimestr( psz_duration, dur/1000000 );
else
memcpy( psz_duration, "-:--:--", sizeof("-:--:--") );
if( !strcmp( psz_author, "" ) )
if( !strcmp( psz_author, "" ) || p_item->input.b_fixed_name == VLC_TRUE )
{
msg.Printf( wxString( wxL2U( p_item->input.psz_name ) ) + wxU( " ( ") +
wxString(wxL2U(psz_duration ) ) + wxU( ")") );
......@@ -735,25 +734,7 @@ void Playlist::UpdatePlaylist()
{
return;
}
#if 0
/* Update the colour of items */
int i_playlist_index = p_playlist->i_index;
if( p_intf->p_sys->i_playing != i_playlist_index )
{
wxListItem listitem;
listitem.m_itemId = i_playlist_index;
listitem.SetTextColour( *wxRED );
listview->SetItem( listitem );
if( p_intf->p_sys->i_playing != -1 )
{
listitem.m_itemId = p_intf->p_sys->i_playing;
listitem.SetTextColour( *wxBLACK );
listview->SetItem( listitem );
}
p_intf->p_sys->i_playing = i_playlist_index;
}
#endif
vlc_object_release( p_playlist );
}
......
......@@ -490,7 +490,6 @@ static int Demux( demux_t *p_demux )
/* Gather the complete sdp file */
for( ;; )
{
fprintf(stderr,"read %i at %p\n",i_max_sdp - i_sdp - 1, &psz_sdp[i_sdp]);
int i_read = stream_Read( p_demux->s,
&psz_sdp[i_sdp], i_max_sdp - i_sdp - 1 );
......@@ -515,7 +514,11 @@ static int Demux( demux_t *p_demux )
p_sdp = ParseSDP( VLC_OBJECT(p_demux), psz_sdp );
if( !p_sdp ) return -1;
if( !p_sdp )
{
msg_Warn( p_demux, "invalid SDP");
return -1;
}
if( p_sdp->i_media > 1 )
{
......@@ -966,6 +969,7 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp )
static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp )
{
sdp_t *p_sdp;
vlc_bool_t b_invalid = VLC_FALSE;
if( psz_sdp == NULL )
{
......@@ -985,6 +989,9 @@ static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp )
p_sdp->psz_sessionname = NULL;
p_sdp->psz_media = NULL;
p_sdp->psz_connection = NULL;
p_sdp->psz_uri = NULL;
p_sdp->psz_address = NULL;
p_sdp->psz_address_type= NULL;
p_sdp->i_media = 0;
p_sdp->i_attributes = 0;
......@@ -1036,13 +1043,25 @@ static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp )
break;
case ( 'o' ):
{
int i_field = 0;
/* o field is <username> <session id> <version>
* <network type> <address type> <address> */
#define GET_FIELD( store ) \
#define GET_FIELD( store ) \
psz_eof = strchr( psz_parse, ' ' ); \
if( psz_eof ) { *psz_eof=0; store = strdup( psz_parse ); } \
else { store = strdup( psz_parse );}; psz_parse = psz_eof + 1 ;
if( psz_eof ) \
{ \
*psz_eof=0; store = strdup( psz_parse ); \
} \
else \
{ \
if( i_field != 5 ) \
{ \
b_invalid = VLC_TRUE; break; \
} \
}; \
psz_parse = psz_eof + 1; i_field++;
psz_parse = &psz_sdp[2];
GET_FIELD( p_sdp->psz_username );
......@@ -1118,6 +1137,12 @@ static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp )
break;
}
if( b_invalid )
{
FreeSDP( p_sdp );
return NULL;
}
psz_sdp = psz_eol;
}
......@@ -1234,6 +1259,10 @@ static void FreeSDP( sdp_t *p_sdp )
FREE( p_sdp->psz_connection );
FREE( p_sdp->psz_media );
FREE( p_sdp->psz_uri );
FREE( p_sdp->psz_address );
FREE( p_sdp->psz_address_type );
for( i= p_sdp->i_attributes - 1; i >= 0 ; i-- )
{
struct attribute_t *p_attr = p_sdp->pp_attributes[i];
......
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