[vlc-commits] demux: adaptative: fix uninitialized thread_t (fix #1346983)

Francois Cartegnie git at videolan.org
Thu Dec 31 16:02:11 CET 2015


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;
     vlc_cond_signal(&waitcond);
-    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;
         };



More information about the vlc-commits mailing list