[vlc-devel] [vlc-commits] demux: adaptative: fix uninitialized thread_t (fix #1346983)
Rémi Denis-Courmont
remi at remlab.net
Thu Dec 31 17:04:10 CET 2015
Le 2015-12-31 17:02, git at videolan.org a écrit :
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu
> Dec 31 15:58:24 2015 +0100|
> [d64372c7c3aee7ae7c4544a53cd7f0b9e829d466]
> | committer: Francois Cartegnie
>
> demux: adaptative: fix uninitialized thread_t (fix #1346983)
>
> Sets dumb initializer, and adds member to avoid joining invalid
> thread reference.
>
>>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d64372c7c3aee7ae7c4544a53cd7f0b9e829d466
> ---
>
> modules/demux/adaptative/http/Downloader.cpp | 9 +++++++--
> modules/demux/adaptative/http/Downloader.hpp | 1 +
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/modules/demux/adaptative/http/Downloader.cpp
> b/modules/demux/adaptative/http/Downloader.cpp
> index 1c44f7f..97fc43a 100644
> --- a/modules/demux/adaptative/http/Downloader.cpp
> +++ b/modules/demux/adaptative/http/Downloader.cpp
> @@ -29,15 +29,19 @@ Downloader::Downloader()
> vlc_mutex_init(&lock);
> vlc_cond_init(&waitcond);
> killed = false;
> + thread_handle = { 0 };
> + thread_handle_valid = false;
> }
>
> 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))
> {
> return false;
> }
> + thread_handle_valid = true;
> return true;
> }
>
> @@ -45,7 +49,8 @@ Downloader::~Downloader()
> {
> killed = true;
Unused value.
> vlc_cond_signal(&waitcond);
Signal without data.
> - vlc_join(thread_handle, NULL);
> + if(thread_handle_valid)
> + vlc_join(thread_handle, NULL);
> vlc_mutex_destroy(&lock);
> vlc_cond_destroy(&waitcond);
> }
> diff --git a/modules/demux/adaptative/http/Downloader.hpp
> b/modules/demux/adaptative/http/Downloader.hpp
> index 64dcf43..2555a70 100644
> --- a/modules/demux/adaptative/http/Downloader.hpp
> +++ b/modules/demux/adaptative/http/Downloader.hpp
> @@ -52,6 +52,7 @@ namespace adaptative
> vlc_mutex_t lock;
> vlc_cond_t waitcond;
> vlc_mutex_t processlock;
> + bool thread_handle_valid;
> bool killed;
> std::list<HTTPChunkBufferedSource *> chunks;
> };
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list