Commit d64372c7 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: fix uninitialized thread_t (fix #1346983)

Sets dumb initializer, and adds member to avoid joining invalid
thread reference.
parent efe5041c
...@@ -29,15 +29,19 @@ Downloader::Downloader() ...@@ -29,15 +29,19 @@ Downloader::Downloader()
vlc_mutex_init(&lock); vlc_mutex_init(&lock);
vlc_cond_init(&waitcond); vlc_cond_init(&waitcond);
killed = false; killed = false;
thread_handle = { 0 };
thread_handle_valid = false;
} }
bool Downloader::start() bool Downloader::start()
{ {
if(vlc_clone(&thread_handle, downloaderThread, if(!thread_handle_valid &&
vlc_clone(&thread_handle, downloaderThread,
reinterpret_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT)) reinterpret_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT))
{ {
return false; return false;
} }
thread_handle_valid = true;
return true; return true;
} }
...@@ -45,7 +49,8 @@ Downloader::~Downloader() ...@@ -45,7 +49,8 @@ Downloader::~Downloader()
{ {
killed = true; killed = true;
vlc_cond_signal(&waitcond); vlc_cond_signal(&waitcond);
vlc_join(thread_handle, NULL); if(thread_handle_valid)
vlc_join(thread_handle, NULL);
vlc_mutex_destroy(&lock); vlc_mutex_destroy(&lock);
vlc_cond_destroy(&waitcond); vlc_cond_destroy(&waitcond);
} }
......
...@@ -52,6 +52,7 @@ namespace adaptative ...@@ -52,6 +52,7 @@ namespace adaptative
vlc_mutex_t lock; vlc_mutex_t lock;
vlc_cond_t waitcond; vlc_cond_t waitcond;
vlc_mutex_t processlock; vlc_mutex_t processlock;
bool thread_handle_valid;
bool killed; bool killed;
std::list<HTTPChunkBufferedSource *> chunks; std::list<HTTPChunkBufferedSource *> chunks;
}; };
......
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