[Fontconfig] fontconfig: Branch 'master'
Akira TAGOH
tagoh at kemper.freedesktop.org
Thu Feb 26 19:05:11 PST 2015
src/fcstat.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
New commits:
commit 97cf7ec4d740c9b3ac7c29388224f5e0c226a120
Author: Akira TAGOH <akira at tagoh.org>
Date: Fri Feb 27 12:04:44 2015 +0900
Rework again to copy the struct dirent
Assuming that d_name is the last member of struct dirent.
In POSIX, the maximum length of d_name is defined as NAME_MAX
or FILENAME_MAX though, that assumption may be wrong on some
platforms where defines d_name as the flexible array member
and allocate the minimum memory to store d_name.
Patch from Raimund Steger
diff --git a/src/fcstat.c b/src/fcstat.c
index d2eb258..d444bf9 100644
--- a/src/fcstat.c
+++ b/src/fcstat.c
@@ -215,13 +215,8 @@ FcScandir (const char *dirp,
{
if (!filter || (filter) (dent))
{
- 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));
- }
+ size_t dentlen = FcPtrToOffset (dent, dent->d_name) + 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)
More information about the Fontconfig
mailing list