[vlc-commits] demux: adaptive: add missing empty adaption set checks

Francois Cartegnie git at videolan.org
Tue Feb 26 20:10:03 CET 2019


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 26 18:54:04 2019 +0100| [8bc534b2984469d765100ccba949d0a3e10c1478] | committer: Francois Cartegnie

demux: adaptive: add missing empty adaption set checks

(cherry picked from commit 7eb24be747ceb5826a47ed17e80c79a570547512)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=8bc534b2984469d765100ccba949d0a3e10c1478
---

 modules/demux/adaptive/playlist/BasePeriod.cpp | 6 ++++++
 modules/demux/dash/mpd/IsoffMainParser.cpp     | 6 +++++-
 modules/demux/hls/playlist/Parser.cpp          | 5 ++++-
 modules/demux/smooth/playlist/Parser.cpp       | 5 ++++-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/demux/adaptive/playlist/BasePeriod.cpp b/modules/demux/adaptive/playlist/BasePeriod.cpp
index 4f520d5bf6..93f4121741 100644
--- a/modules/demux/adaptive/playlist/BasePeriod.cpp
+++ b/modules/demux/adaptive/playlist/BasePeriod.cpp
@@ -32,6 +32,7 @@
 
 #include <vlc_common.h>
 #include <vlc_arrays.h>
+#include <cassert>
 
 using namespace adaptive::playlist;
 
@@ -63,6 +64,11 @@ void BasePeriod::addAdaptationSet(BaseAdaptationSet *adaptationSet)
 {
     if ( adaptationSet != NULL )
     {
+        if(adaptationSet->getRepresentations().empty())
+        {
+            assert(!adaptationSet->getRepresentations().empty());
+            return; /* will leak */
+        }
         adaptationSets.push_back(adaptationSet);
         childs.push_back(adaptationSet);
     }
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 23d0e5e117..0401d1bf98 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -264,7 +264,11 @@ void    IsoffMainParser::parseAdaptationSets  (Node *periodNode, Period *period)
         parseSegmentInformation(*it, adaptationSet, &nextid);
 
         parseRepresentations((*it), adaptationSet);
-        period->addAdaptationSet(adaptationSet);
+
+        if(!adaptationSet->getRepresentations().empty())
+            period->addAdaptationSet(adaptationSet);
+        else
+            delete adaptationSet;
     }
 }
 void    IsoffMainParser::parseRepresentations (Node *adaptationSetNode, AdaptationSet *adaptationSet)
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index b5490248c4..2371152a75 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -516,10 +516,13 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::
         BaseAdaptationSet *adaptSet = new (std::nothrow) BaseAdaptationSet(period);
         if(adaptSet)
         {
-            period->addAdaptationSet(adaptSet);
             AttributesTag *tag = new AttributesTag(AttributesTag::EXTXSTREAMINF, "");
             tag->addAttribute(new Attribute("URI", playlisturl));
             createAndFillRepresentation(p_object, adaptSet, tag, tagslist);
+            if(!adaptSet->getRepresentations().empty())
+                period->addAdaptationSet(adaptSet);
+            else
+                delete adaptSet;
             delete tag;
         }
     }
diff --git a/modules/demux/smooth/playlist/Parser.cpp b/modules/demux/smooth/playlist/Parser.cpp
index eb16da463b..3868125823 100644
--- a/modules/demux/smooth/playlist/Parser.cpp
+++ b/modules/demux/smooth/playlist/Parser.cpp
@@ -248,7 +248,10 @@ static void ParseStreamIndex(BasePeriod *period, Node *streamIndexNode, unsigned
             for(it = qualLevels.begin(); it != qualLevels.end(); ++it)
                 ParseQualityLevel(adaptSet, *it, type, nextid++, id);
         }
-        period->addAdaptationSet(adaptSet);
+        if(!adaptSet->getRepresentations().empty())
+            period->addAdaptationSet(adaptSet);
+        else
+            delete adaptSet;
     }
 }
 



More information about the vlc-commits mailing list