[vlc-devel] [PATCH] demux: adaptive: fix null-pointer dereference and race condition
Zhao Zhili
quinkblack at foxmail.com
Tue Aug 7 05:12:03 CEST 2018
---
modules/demux/adaptive/http/Chunk.cpp | 9 ++++++++-
modules/demux/adaptive/http/Chunk.h | 3 +++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index a4269e3..d8bc0f3 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -136,6 +136,7 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManag
prepared = false;
eof = false;
sourceid = id;
+ vlc_mutex_init(&contentTypeLock);
setUseAccess(access);
if(!init(url))
eof = true;
@@ -145,6 +146,7 @@ HTTPChunkSource::~HTTPChunkSource()
{
if(connection)
connection->setUsed(false);
+ vlc_mutex_destroy(&contentTypeLock);
}
bool HTTPChunkSource::init(const std::string &url)
@@ -218,7 +220,8 @@ block_t * HTTPChunkSource::read(size_t readsize)
std::string HTTPChunkSource::getContentType() const
{
- return connection->getContentType();
+ vlc_mutex_locker locker(const_cast<vlc_mutex_t *>(&contentTypeLock));
+ return contentType;
}
bool HTTPChunkSource::prepare()
@@ -261,6 +264,10 @@ bool HTTPChunkSource::prepare()
from content length */
contentLength = connection->getContentLength();
prepared = true;
+ {
+ vlc_mutex_locker locker(&contentTypeLock);
+ contentType = connection->getContentType();
+ }
return true;
}
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index 3bf3b44..1ec5671 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -109,6 +109,9 @@ namespace adaptive
private:
bool init(const std::string &);
ConnectionParams params;
+
+ vlc_mutex_t contentTypeLock;
+ std::string contentType;
};
class HTTPChunkBufferedSource : public HTTPChunkSource
--
2.9.5
More information about the vlc-devel
mailing list