Commit 1fffacd6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

libvlc: fix race on input_item_t.p_stats

p_stats is written with the input item lock (by the input thread).
Thus the input item lock is necessary to read and dereference p_stats.
parent 895d480b
......@@ -698,10 +698,20 @@ libvlc_media_subitems( libvlc_media_t * p_md )
int libvlc_media_get_stats( libvlc_media_t *p_md,
libvlc_media_stats_t *p_stats )
{
input_item_t *item = p_md->p_input_item;
if( !p_md->p_input_item )
return false;
vlc_mutex_lock( &item->lock );
input_stats_t *p_itm_stats = p_md->p_input_item->p_stats;
if( p_itm_stats == NULL )
{
vlc_mutex_unlock( &item->lock );
return false;
}
vlc_mutex_lock( &p_itm_stats->lock );
p_stats->i_read_bytes = p_itm_stats->i_read_bytes;
p_stats->f_input_bitrate = p_itm_stats->f_input_bitrate;
......@@ -724,6 +734,7 @@ int libvlc_media_get_stats( libvlc_media_t *p_md,
p_stats->i_sent_bytes = p_itm_stats->i_sent_bytes;
p_stats->f_send_bitrate = p_itm_stats->f_send_bitrate;
vlc_mutex_unlock( &p_itm_stats->lock );
vlc_mutex_unlock( &item->lock );
return true;
}
......
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