[vlc-commits] stream_filter/httplive.c: Do not crash when Prefetch() fails

Jean-Paul Saman git at videolan.org
Wed Jan 19 17:00:15 CET 2011


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Jan 19 16:53:13 2011 +0100| [c761818073f2fb648f7efa9c8ba3b0a5f58f0b7e] | committer: Jean-Paul Saman

stream_filter/httplive.c: Do not crash when Prefetch() fails

If Prefetch() decides that playback cannot commence it returns VLC_EGENERIC. The
code path in Open() tries to cleanup by calling Close(). However at that point the
hls_Thread() is not started yet and this causes a crash in Close().

The resolution is to not call Close() but cleanup the parts that have been created
in the Open() function itself.

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

 modules/stream_filter/httplive.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 641856b..118440e 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1548,6 +1548,7 @@ static int Open(vlc_object_t *p_this)
     p_sys->hls_stream = vlc_array_new();
     if (p_sys->hls_stream == NULL)
     {
+        vlc_UrlClean(&p_sys->m3u8);
         free(p_sys);
         return VLC_ENOMEM;
     }
@@ -1559,9 +1560,7 @@ static int Open(vlc_object_t *p_this)
 
     /* Select first segment to play */
     if (parse_HTTPLiveStreaming(s) != VLC_SUCCESS)
-    {
         goto fail;
-    }
 
     /* Choose first HLS stream to start with */
     int current = p_sys->playback.stream = 0;
@@ -1593,13 +1592,28 @@ static int Open(vlc_object_t *p_this)
     if (vlc_thread_create(s, "HTTP Live Streaming client",
                           hls_Thread, VLC_THREAD_PRIORITY_INPUT))
     {
-        goto fail;
+        goto fail_thread;
     }
 
     return VLC_SUCCESS;
 
+fail_thread:
+    vlc_mutex_destroy(&p_sys->download.lock_wait);
+    vlc_cond_destroy(&p_sys->download.wait);
+
 fail:
-    Close(p_this);
+    /* Free hls streams */
+    for (int i = 0; i < vlc_array_count(p_sys->hls_stream); i++)
+    {
+        hls_stream_t *hls;
+        hls = (hls_stream_t *)vlc_array_item_at_index(p_sys->hls_stream, i);
+        if (hls) hls_Free(hls);
+    }
+    vlc_array_destroy(p_sys->hls_stream);
+
+    /* */
+    vlc_UrlClean(&p_sys->m3u8);
+    free(p_sys);
     return VLC_EGENERIC;
 }
 



More information about the vlc-commits mailing list