]> git.sesse.net Git - vlc/commitdiff
fix crash with directory access
authorRafaël Carré <funman@videolan.org>
Sat, 19 Nov 2011 22:04:35 +0000 (17:04 -0500)
committerRafaël Carré <funman@videolan.org>
Sat, 19 Nov 2011 22:08:13 +0000 (17:08 -0500)
If a directory was not valid UTF-8, convert_xml_special_chars() would
return NULL, we'd have no title to give to our node, and we'd use
freed memory when adding the next node to the list.

Ensure we give valid UTF-8 to convert_xml_special_chars()
Also ensure we give a title to our node in any case

modules/access/directory.c

index eff8d572c118285a5d9ea4c864040742cba9c78e..f958e12cc4a0a4d5a2b19ea690867f4124877161 100644 (file)
@@ -49,6 +49,7 @@
 #include <vlc_fs.h>
 #include <vlc_url.h>
 #include <vlc_strings.h>
+#include <vlc_charset.h>
 
 enum
 {
@@ -375,10 +376,11 @@ block_t *DirBlock (access_t *p_access)
 
         /* Add node to XSPF extension */
         char *old_xspf_ext = p_sys->xspf_ext;
+        EnsureUTF8 (entry);
         char *title = convert_xml_special_chars (entry);
-        if (old_xspf_ext != NULL && title != NULL
+        if (old_xspf_ext != NULL
          && asprintf (&p_sys->xspf_ext, "%s  <vlc:node title=\"%s\">\n",
-                      old_xspf_ext, title) == -1)
+                      old_xspf_ext, title ? title : "?") == -1)
             p_sys->xspf_ext = NULL;
         free (old_xspf_ext);
         free (title);