[vlc-commits] demux: playlist: xspf: really fix skip_element

Francois Cartegnie git at videolan.org
Fri Sep 8 13:59:54 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep  8 12:19:58 2017 +0200| [d99cad93c6ee23c3f58c4c069f341c873c10e6fd] | committer: Francois Cartegnie

demux: playlist: xspf: really fix skip_element

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

 modules/demux/playlist/xspf.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 88d4fdf296..72884d056d 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -696,26 +696,35 @@ static bool skip_element COMPLEX_INTERFACE
     if(b_empty_node)
         return true;
 
+    /* Const reference changes if we read again */
+    char *psz_end = psz_element ? strdup(psz_element) : NULL;
     const char *name;
-    for (unsigned lvl = 1; lvl;)
+    unsigned lvl = 1;
+    bool b_ret = true;
+    while(lvl > 0 && b_ret)
+    {
         switch (xml_ReaderNextNode(p_xml_reader, &name))
         {
             case XML_READER_STARTELEM:
-            {
                 if( !xml_ReaderIsEmptyElement( p_xml_reader ) )
                     ++lvl;
                 break;
-            }
             case XML_READER_ENDELEM:
-                if(lvl == 1 &&
-                    name && psz_element && strcmp(psz_element, name))
-                        return false;
                 lvl--;
                 break;
             case XML_READER_NONE:
             case XML_READER_ERROR:
-                return false;
+                b_ret = false;
+                break;
+            default:
+                break;
         }
+    }
 
-    return true;
+    if(b_ret) /* Ensure we end on same node type */
+        b_ret &= (!name || !psz_end || !strcmp(psz_end, name));
+
+    free(psz_end);
+
+    return b_ret;
 }



More information about the vlc-commits mailing list