Commit 6357ef21 authored by Rémi Duraffort's avatar Rémi Duraffort

Fix potential segfault and move code (CID 178)

parent bcd40e9a
...@@ -345,24 +345,21 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl, ...@@ -345,24 +345,21 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
playlist_item_t *p_node, char *name, mvar_t *s, playlist_item_t *p_node, char *name, mvar_t *s,
int i_depth ) int i_depth )
{ {
if( p_node != NULL ) if( !p_node || !p_node->p_input )
{ return;
if( p_node->i_children == -1 ) if( p_node->i_children == -1 )
{ {
char value[512]; char value[512];
char *psz; char *psz;
mvar_t *itm = mvar_New( name, "set" ); mvar_t *itm = mvar_New( name, "set" );
playlist_item_t * p_item = playlist_CurrentPlayingItem(p_pl); playlist_item_t * p_item = playlist_CurrentPlayingItem( p_pl );
if( p_item && p_node && if( !p_item || !p_item->p_input )
p_item->p_input && p_node->p_input && return;
p_item->p_input->i_id == p_node->p_input->i_id ) if( p_item->p_input->i_id == p_node->p_input->i_id )
{
mvar_AppendNewVar( itm, "current", "1" ); mvar_AppendNewVar( itm, "current", "1" );
}
else else
{
mvar_AppendNewVar( itm, "current", "0" ); mvar_AppendNewVar( itm, "current", "0" );
}
sprintf( value, "%d", p_node->i_id ); sprintf( value, "%d", p_node->i_id );
mvar_AppendNewVar( itm, "index", value ); mvar_AppendNewVar( itm, "index", value );
...@@ -382,13 +379,9 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl, ...@@ -382,13 +379,9 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
mvar_AppendNewVar( itm, "depth", value ); mvar_AppendNewVar( itm, "depth", value );
if( p_node->i_flags & PLAYLIST_RO_FLAG ) if( p_node->i_flags & PLAYLIST_RO_FLAG )
{
mvar_AppendNewVar( itm, "ro", "ro" ); mvar_AppendNewVar( itm, "ro", "ro" );
}
else else
{
mvar_AppendNewVar( itm, "ro", "rw" ); mvar_AppendNewVar( itm, "ro", "rw" );
}
sprintf( value, "%ld", sprintf( value, "%ld",
(long) input_item_GetDuration( p_node->p_input ) ); (long) input_item_GetDuration( p_node->p_input ) );
...@@ -418,22 +411,15 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl, ...@@ -418,22 +411,15 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
mvar_AppendNewVar( itm, "depth", value ); mvar_AppendNewVar( itm, "depth", value );
if( p_node->i_flags & PLAYLIST_RO_FLAG ) if( p_node->i_flags & PLAYLIST_RO_FLAG )
{
mvar_AppendNewVar( itm, "ro", "ro" ); mvar_AppendNewVar( itm, "ro", "ro" );
}
else else
{
mvar_AppendNewVar( itm, "ro", "rw" ); mvar_AppendNewVar( itm, "ro", "rw" );
}
mvar_AppendVar( s, itm ); mvar_AppendVar( s, itm );
for (i_child = 0 ; i_child < p_node->i_children ; i_child++) for( i_child = 0 ; i_child < p_node->i_children ; i_child++ )
PlaylistListNode( p_intf, p_pl, PlaylistListNode( p_intf, p_pl, p_node->pp_children[i_child],
p_node->pp_children[i_child],
name, s, i_depth + 1); name, s, i_depth + 1);
}
} }
} }
......
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