[vlc-commits] demux/adaptive: DOMParser: retain root element if empty

Filip Roséen git at videolan.org
Wed Mar 15 19:22:13 CET 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Mar 15 10:06:48 2017 +0100| [9ac321c628f7b13cb951122094429be78c682c4f] | committer: Jean-Baptiste Kempf

demux/adaptive: DOMParser: retain root element if empty

An XML file containing a single root element without children would,
given the previous implementation, have its only element ignored.
Resulting in a memory-leak of the node in question, while also (more
importantly) making it impossible to access the associated data.

As XML does not allow documents such as the below (only a single root
is allowed):

   <?xml version="1.0">
   <ill-formed />
   <ill-formed></ill-formed>

Simply checking to see so that we are not popping away all our tags
are sufficient in order to fix this bug. The changes also make sure
that we do not invoke std::stack<...>::pop on an empty container
(which is undefined-behavior).

fixes: #18122

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/demux/adaptive/xml/DOMParser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/demux/adaptive/xml/DOMParser.cpp b/modules/demux/adaptive/xml/DOMParser.cpp
index a8a6621..648c14b 100644
--- a/modules/demux/adaptive/xml/DOMParser.cpp
+++ b/modules/demux/adaptive/xml/DOMParser.cpp
@@ -112,7 +112,7 @@ Node* DOMParser::processNode(bool b_strict)
                     addAttributesToNode(node);
                 }
 
-                if(empty)
+                if(empty && lifo.size() > 1)
                     lifo.pop();
                 break;
             }



More information about the vlc-commits mailing list