X-Git-Url: https://git.wh0rd.org/?p=fontconfig.git;a=blobdiff_plain;f=src%2Ffccfg.c;h=09c59919d8f37bd1998f7d530f7b96865512b8a2;hp=4beb7d23688b8f97a423e60d85de4f34cf873bca;hb=1c475d5c8cb265ac939d6b9e097666e300162511;hpb=f0ee5761e1ab63d848f980a767dd8475986f1342 diff --git a/src/fccfg.c b/src/fccfg.c index 4beb7d2..09c5991 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -1689,10 +1689,19 @@ static FcChar8 * FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) { FcChar8 *path; + int size; if (!dir) dir = (FcChar8 *) ""; - path = malloc (strlen ((char *) dir) + 1 + strlen ((char *) file) + 1); + + size = strlen ((char *) dir) + 1 + strlen ((char *) file) + 1; + /* + * workaround valgrind warning because glibc takes advantage of how it knows memory is + * allocated to implement strlen by reading in groups of 4 + */ + size = (size + 3) & ~3; + + path = malloc (size); if (!path) return 0; @@ -1711,7 +1720,7 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) #endif strcat ((char *) path, (char *) file); - FcMemAlloc (FC_MEM_STRING, strlen ((char *) path) + 1); + FcMemAlloc (FC_MEM_STRING, size); if (access ((char *) path, R_OK) == 0) return path;