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

Francois Cartegnie git at videolan.org
Tue Feb 26 18:59:37 CET 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 26 18:54:04 2019 +0100| [7eb24be747ceb5826a47ed17e80c79a570547512] | committer: Francois Cartegnie

demux: adaptive: add missing empty adaption set checks

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7eb24be747ceb5826a47ed17e80c79a570547512
---

 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 7cee301f5f..971851c611 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 42baf0381a..1ec3402496 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -267,7 +267,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 9bb06ef0bc..5d67e160a2 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