[vlc-devel] [PATCH 4/9] demux/playlist: xspf: only use text-elements inside current tag

Filip Roséen filip at atch.se
Thu May 18 12:08:22 CEST 2017


These changes adds logic to not use an out-of-text text-element when
parsing an upcoming tag, as the text-element certainly is not part of
a tag that has not yet been parsed.

More accurately, a text-node that exists prior to an element that
has no text-body would previously inaccurately be treated as if it was
inside said element.

fixes: #18336
---
 modules/demux/playlist/xspf.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 35c66978fb..590da3a511 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -239,6 +239,8 @@ static bool parse_playlist_node COMPLEX_INTERFACE
     {
     /*  element start tag  */
     case XML_READER_STARTELEM:
+        FREENULL(psz_value);
+
         if (!*name)
         {
             msg_Err(p_demux, "invalid XML stream");
@@ -254,7 +256,6 @@ static bool parse_playlist_node COMPLEX_INTERFACE
         /* complex content is parsed in a separate function */
         if (p_handler->cmplx)
         {
-            FREENULL(psz_value);
             if (!p_handler->pf_handler.cmplx(p_demux, p_input_node,
                         p_xml_reader, p_handler->name))
                 return false;
@@ -385,6 +386,8 @@ static bool parse_track_node COMPLEX_INTERFACE
     {
     /*  element start tag  */
     case XML_READER_STARTELEM:
+        FREENULL(psz_value);
+
         if (!*name)
         {
             msg_Err(p_demux, "invalid XML stream");
@@ -400,8 +403,6 @@ static bool parse_track_node COMPLEX_INTERFACE
         /* complex content is parsed in a separate function */
         if (p_handler->cmplx)
         {
-            FREENULL(psz_value);
-
             if (!p_handler->pf_handler.cmplx(p_demux, p_new_node,
                                              p_xml_reader, p_handler->name)) {
                 input_item_node_Delete(p_new_node);
@@ -660,10 +661,11 @@ static bool parse_extension_node COMPLEX_INTERFACE
         {
             /*  element start tag  */
             case XML_READER_STARTELEM:
+                FREENULL(psz_value);
+
                 if (!*name)
                 {
                     msg_Err(p_demux, "invalid xml stream");
-                    FREENULL(psz_value);
                     if (b_release_input_item) input_item_Release(p_new_input);
                     return false;
                 }
@@ -672,7 +674,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 if (!p_handler)
                 {
                     msg_Err(p_demux, "unexpected element <%s>", name);
-                    FREENULL(psz_value);
                     if (b_release_input_item) input_item_Release(p_new_input);
                     return false;
                 }
@@ -685,11 +686,9 @@ static bool parse_extension_node COMPLEX_INTERFACE
                                                      p_handler->name))
                     {
                         p_handler = NULL;
-                        FREENULL(psz_value);
                     }
                     else
                     {
-                        FREENULL(psz_value);
                         if (b_release_input_item)
                             input_item_Release(p_new_input);
                         return false;
-- 
2.12.2


More information about the vlc-devel mailing list