Commit 58ac662c authored by Rafaël Carré's avatar 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
parent 8a2ce299
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include <vlc_fs.h> #include <vlc_fs.h>
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#include <vlc_charset.h>
enum enum
{ {
...@@ -375,10 +376,11 @@ block_t *DirBlock (access_t *p_access) ...@@ -375,10 +376,11 @@ block_t *DirBlock (access_t *p_access)
/* Add node to XSPF extension */ /* Add node to XSPF extension */
char *old_xspf_ext = p_sys->xspf_ext; char *old_xspf_ext = p_sys->xspf_ext;
EnsureUTF8 (entry);
char *title = convert_xml_special_chars (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", && 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; p_sys->xspf_ext = NULL;
free (old_xspf_ext); free (old_xspf_ext);
free (title); free (title);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment