Commit 8809d1b7 authored by Akira TAGOH's avatar Akira TAGOH
Browse files

Copy the real size of struct dirent

In some platforms, d_name is defined as the flexible array member.
We may need to compute the real size for that case.
parent dd427253
......@@ -680,6 +680,7 @@ dnl Figure out what cache format suffix to use for this architecture
AC_C_BIGENDIAN
AC_CHECK_SIZEOF([void *])
AC_CHECK_ALIGNOF([double])
AC_CHECK_ALIGNOF([void *])
dnl include the header file for workaround of miscalculating size on autoconf
dnl particularly for fat binaries
......
......@@ -215,8 +215,15 @@ FcScandir (const char *dirp,
{
if (!filter || (filter) (dent))
{
p = (struct dirent *) malloc (sizeof (struct dirent));
memcpy (p, dent, sizeof (struct dirent));
size_t dentlen = sizeof (struct dirent);
if (sizeof (struct dirent) == FcPtrToOffset (dent, dent->d_name))
{
dentlen += strlen (dent->d_name) + 1;
dentlen = ((dentlen + ALIGNOF_VOID_P - 1) & ~(ALIGNOF_VOID_P - 1));
}
p = (struct dirent *) malloc (dentlen);
memcpy (p, dent, dentlen);
if (n >= lsize)
{
lsize += 128;
......
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