Commit be14e277 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

"Improve" readdir_r() usage

parent aca469a2
...@@ -191,15 +191,15 @@ char *vlc_readdir( DIR *dir ) ...@@ -191,15 +191,15 @@ char *vlc_readdir( DIR *dir )
char *path = NULL; char *path = NULL;
long len = fpathconf (dirfd (dir), _PC_NAME_MAX); long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
if (len == -1)
{
#ifdef NAME_MAX #ifdef NAME_MAX
/* POSIX says there shall we room for NAME_MAX bytes at all times */
if (/*len == -1 ||*/ len < NAME_MAX)
len = NAME_MAX; len = NAME_MAX;
#else #else
errno = ENOMEM; /* OS is broken. Lets assume there is no files left. */
return NULL; // OS is broken. There is no sane way to fix this. if (len == -1)
return NULL;
#endif #endif
}
len += offsetof (struct dirent, d_name) + 1; len += offsetof (struct dirent, d_name) + 1;
struct dirent *buf = malloc (len); struct dirent *buf = malloc (len);
......
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