[vlc-commits] hds: avoid crashing when no streams are present

Tristan Matthews git at videolan.org
Thu Jul 17 21:46:06 CEST 2014


vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Thu Jul 17 14:03:19 2014 -0400| [8466eebfd51a5ffa5a0b262d55f3cc70f3b1c219] | committer: Tristan Matthews

hds: avoid crashing when no streams are present

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8466eebfd51a5ffa5a0b262d55f3cc70f3b1c219
---

 modules/stream_filter/hds/hds.c |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/modules/stream_filter/hds/hds.c b/modules/stream_filter/hds/hds.c
index 5119ba2..8c7d3a5 100644
--- a/modules/stream_filter/hds/hds.c
+++ b/modules/stream_filter/hds/hds.c
@@ -771,6 +771,9 @@ static void* download_thread( void* p )
     stream_t* s = (stream_t*) p_this;
     stream_sys_t* sys = s->p_sys;
 
+    if ( vlc_array_count( sys->hds_streams ) == 0 )
+        return NULL;
+
     // TODO: Change here for selectable stream
     hds_stream_t* hds_stream = sys->hds_streams->pp_elems[0];
 
@@ -1012,6 +1015,9 @@ static void* live_thread( void* p )
     stream_t* s = (stream_t*) p_this;
     stream_sys_t* sys = s->p_sys;
 
+    if ( vlc_array_count( sys->hds_streams ) == 0 )
+        return NULL;
+
     // TODO: Change here for selectable stream
     hds_stream_t* hds_stream = sys->hds_streams->pp_elems[0];
 
@@ -1436,15 +1442,21 @@ static void Close( vlc_object_t *p_this )
     stream_sys_t *p_sys = s->p_sys;
 
     // TODO: Change here for selectable stream
-    hds_stream_t *stream = s->p_sys->hds_streams->pp_elems[0];
+    hds_stream_t *stream = vlc_array_count(p_sys->hds_streams) ?
+        s->p_sys->hds_streams->pp_elems[0] : NULL;
 
     p_sys->closed = true;
-    vlc_cond_signal( & stream->dl_cond );
+    if (stream)
+        vlc_cond_signal( & stream->dl_cond );
 
     vlc_join( p_sys->dl_thread, NULL );
-    vlc_mutex_destroy( &stream->dl_lock );
-    vlc_cond_destroy( &stream->dl_cond );
-    vlc_mutex_destroy( &stream->abst_lock );
+
+    if (stream)
+    {
+        vlc_mutex_destroy( &stream->dl_lock );
+        vlc_cond_destroy( &stream->dl_cond );
+        vlc_mutex_destroy( &stream->abst_lock );
+    }
 
     if( p_sys->live )
     {
@@ -1595,6 +1607,9 @@ static int Read( stream_t *s, void *buffer, unsigned i_read )
 {
     stream_sys_t *p_sys = s->p_sys;
 
+    if ( vlc_array_count( p_sys->hds_streams ) == 0 )
+        return 0;
+
     // TODO: change here for selectable stream
     hds_stream_t *stream = s->p_sys->hds_streams->pp_elems[0];
     int length = 0;
@@ -1622,6 +1637,9 @@ static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned i_peek )
 {
     stream_sys_t *p_sys = s->p_sys;
 
+    if ( vlc_array_count( p_sys->hds_streams ) == 0 )
+        return 0;
+
     // TODO: change here for selectable stream
     hds_stream_t *stream = p_sys->hds_streams->pp_elems[0];
 



More information about the vlc-commits mailing list