[vlc-commits] fix crash with directory access

Rafaël Carré git at videolan.org
Sat Nov 19 23:08:23 CET 2011


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sat Nov 19 17:04:35 2011 -0500| [58ac662cc1f756c1fa9c9bd3315f91923739bd45] | committer: Rafaël Carré

fix crash with directory access

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

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

 modules/access/directory.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index eff8d57..f958e12 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -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);



More information about the vlc-commits mailing list