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;
#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;
if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1)))
return (FcChar8 *) (b + 1);
size = sizeof (struct objectBucket) + strlen ((char *)name) + 1;
- b = malloc (size + sizeof (int));
- /* workaround glibc bug which reads strlen in groups of 4 */
- FcMemAlloc (FC_MEM_STATICSTR, size + sizeof (int));
+ /*
+ * 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;
+ b = malloc (size);
+ FcMemAlloc (FC_MEM_STATICSTR, size);
if (!b)
return NULL;
b->next = 0;