#ifndef WIN32
struct stat st;
#endif
- char path[1];
+#ifndef HAVE_FDOPENDIR
+ char *path;
+#endif
};
struct access_sys_t
p_sys->current = current->parent;
closedir (current->handle);
free (current->uri);
+#ifndef HAVE_FDOPENDIR
+ free (current->path);
+#endif
free (current);
}
memcpy (block->p_buffer, header, sizeof (header) - 1);
/* "Open" the base directory */
- current = malloc (sizeof (*current) + strlen (p_access->psz_path));
+ current = malloc (sizeof (*current));
if (current == NULL)
{
block_Release (block);
}
current->parent = NULL;
current->handle = p_sys->handle;
- strcpy (current->path, p_access->psz_path);
+#ifndef HAVE_FDOPENDIR
+ current->path = strdup (p_access->psz_path);
+#endif
current->uri = p_sys->uri;
if (fstat (dirfd (current->handle), ¤t->st))
{
closedir (current->handle);
p_sys->current = current->parent;
free (current->uri);
+#ifndef HAVE_FDOPENDIR
+ free (current->path);
+#endif
free (current);
if (p_sys->current == NULL)
/* Handle recursion */
if (p_sys->mode != MODE_COLLAPSE)
{
- directory_t *sub = malloc (sizeof (*sub) + strlen (current->path) + 1
- + strlen (entry));
+ directory_t *sub = malloc (sizeof (*sub));
if (sub == NULL)
{
free (entry);
return NULL;
}
- sprintf (sub->path, "%s/%s", current->path, entry);
DIR *handle;
#ifdef HAVE_FDOPENDIR
else
handle = NULL;
#else
- handle = vlc_opendir (sub->path);
+ if (asprintf (&sub->path, "%s/%s", current->path, entry) != -1)
+ handle = vlc_opendir (sub->path);
+ else
+ handle = NULL;
#endif
if (handle != NULL)
{