Commit c7618180 authored by Jean-Paul Saman's avatar 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.
parent c5f5039b
...@@ -1548,6 +1548,7 @@ static int Open(vlc_object_t *p_this) ...@@ -1548,6 +1548,7 @@ static int Open(vlc_object_t *p_this)
p_sys->hls_stream = vlc_array_new(); p_sys->hls_stream = vlc_array_new();
if (p_sys->hls_stream == NULL) if (p_sys->hls_stream == NULL)
{ {
vlc_UrlClean(&p_sys->m3u8);
free(p_sys); free(p_sys);
return VLC_ENOMEM; return VLC_ENOMEM;
} }
...@@ -1559,9 +1560,7 @@ static int Open(vlc_object_t *p_this) ...@@ -1559,9 +1560,7 @@ static int Open(vlc_object_t *p_this)
/* Select first segment to play */ /* Select first segment to play */
if (parse_HTTPLiveStreaming(s) != VLC_SUCCESS) if (parse_HTTPLiveStreaming(s) != VLC_SUCCESS)
{
goto fail; goto fail;
}
/* Choose first HLS stream to start with */ /* Choose first HLS stream to start with */
int current = p_sys->playback.stream = 0; int current = p_sys->playback.stream = 0;
...@@ -1593,13 +1592,28 @@ static int Open(vlc_object_t *p_this) ...@@ -1593,13 +1592,28 @@ static int Open(vlc_object_t *p_this)
if (vlc_thread_create(s, "HTTP Live Streaming client", if (vlc_thread_create(s, "HTTP Live Streaming client",
hls_Thread, VLC_THREAD_PRIORITY_INPUT)) hls_Thread, VLC_THREAD_PRIORITY_INPUT))
{ {
goto fail; goto fail_thread;
} }
return VLC_SUCCESS; return VLC_SUCCESS;
fail_thread:
vlc_mutex_destroy(&p_sys->download.lock_wait);
vlc_cond_destroy(&p_sys->download.wait);
fail: 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; return VLC_EGENERIC;
} }
......
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