diff options
Diffstat (limited to 'fontconfig')
-rw-r--r-- | fontconfig/conf.d/50-user.conf | 7 | ||||
-rw-r--r-- | fontconfig/configure.ac | 2 | ||||
-rw-r--r-- | fontconfig/src/fccfg.c | 2 | ||||
-rw-r--r-- | fontconfig/src/fcdir.c | 14 | ||||
-rw-r--r-- | fontconfig/src/fcinit.c | 16 | ||||
-rw-r--r-- | fontconfig/src/fcint.h | 3 | ||||
-rw-r--r-- | fontconfig/src/fclang.c | 26 | ||||
-rw-r--r-- | fontconfig/src/fcstr.c | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | fontconfig/src/fcxml.c | 34 |
9 files changed, 82 insertions, 27 deletions
diff --git a/fontconfig/conf.d/50-user.conf b/fontconfig/conf.d/50-user.conf index 2f1040898..07c9182e7 100644 --- a/fontconfig/conf.d/50-user.conf +++ b/fontconfig/conf.d/50-user.conf @@ -1,7 +1,12 @@ <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> - <!-- Load per-user customization file --> + <!-- + Load per-user customization files where stored on XDG Base Directory + specification compliant places. it should be usually: + $HOME/.config/fontconfig/conf.d + $HOME/.config/fontconfig/fonts.conf + --> <include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include> <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> <!-- the following elements will be removed in the future --> diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac index 6d5ce7e77..5657bb5d1 100644 --- a/fontconfig/configure.ac +++ b/fontconfig/configure.ac @@ -137,7 +137,7 @@ AC_TYPE_PID_T # Checks for library functions. AC_FUNC_VPRINTF AC_FUNC_MMAP -AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r regcomp regerror regexec regfree fstatvfs fstatfs]) +AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r regcomp regerror regexec regfree fstatvfs fstatfs lstat]) dnl AC_CHECK_FUNCS doesn't check for header files. dnl posix_fadvise() may be not available in older libc. diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index d3752e552..45b486945 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -1743,6 +1743,8 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) #else if ((!path[0] || path[strlen((char *) path)-1] != '/') && file[0] != '/') strcat ((char *) path, "/"); + else + osize--; #endif strcat ((char *) path, (char *) file); diff --git a/fontconfig/src/fcdir.c b/fontconfig/src/fcdir.c index 2b476e8b9..6869ea179 100644 --- a/fontconfig/src/fcdir.c +++ b/fontconfig/src/fcdir.c @@ -35,6 +35,20 @@ FcFileIsDir (const FcChar8 *file) return S_ISDIR(statb.st_mode); } +FcBool +FcFileIsLink (const FcChar8 *file) +{ +#if HAVE_LSTAT + struct stat statb; + + if (lstat ((const char *)file, &statb) != 0) + return FcFalse; + return S_ISLNK (statb.st_mode); +#else + return FcFalse; +#endif +} + static FcBool FcFileScanFontConfig (FcFontSet *set, FcBlanks *blanks, diff --git a/fontconfig/src/fcinit.c b/fontconfig/src/fcinit.c index ab6401215..606483d8d 100644 --- a/fontconfig/src/fcinit.c +++ b/fontconfig/src/fcinit.c @@ -72,7 +72,7 @@ FcInitLoadConfig (void) if (config->cacheDirs && config->cacheDirs->num == 0) { - FcChar8 *prefix; + FcChar8 *prefix, *p; size_t plen; fprintf (stderr, @@ -81,12 +81,15 @@ FcInitLoadConfig (void) "Fontconfig warning: adding <cachedir>%s</cachedir>\n", FC_CACHEDIR); prefix = FcConfigXdgCacheHome (); - plen = prefix ? strlen ((const char *)prefix) : 0; if (!prefix) goto bail; - prefix = realloc (prefix, plen + 12); - if (!prefix) + plen = strlen ((const char *)prefix); + p = realloc (prefix, plen + 12); + if (!p) goto bail; + prefix = p; + FcMemFree (FC_MEM_STRING, plen + 1); + FcMemAlloc (FC_MEM_STRING, plen + 12); memcpy (&prefix[plen], FC_DIR_SEPARATOR_S "fontconfig", 11); prefix[plen + 11] = 0; fprintf (stderr, @@ -98,11 +101,12 @@ FcInitLoadConfig (void) bail: fprintf (stderr, "Fontconfig error: out of memory"); - free (prefix); + if (prefix) + FcStrFree (prefix); FcConfigDestroy (config); return FcInitFallbackConfig (); } - free (prefix); + FcStrFree (prefix); } return config; diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h index 7125f2e5e..87c7b9a9f 100644 --- a/fontconfig/src/fcint.h +++ b/fontconfig/src/fcint.h @@ -764,6 +764,9 @@ FcGetDefaultLang (void); /* fcdir.c */ FcPrivate FcBool +FcFileIsLink (const FcChar8 *file); + +FcPrivate FcBool FcFileScanConfig (FcFontSet *set, FcStrSet *dirs, FcBlanks *blanks, diff --git a/fontconfig/src/fclang.c b/fontconfig/src/fclang.c index b7e70fcfb..65d22a932 100644 --- a/fontconfig/src/fclang.c +++ b/fontconfig/src/fclang.c @@ -182,7 +182,7 @@ FcLangNormalize (const FcChar8 *lang) { FcChar8 *result = NULL, *s, *orig; char *territory, *encoding, *modifier; - size_t llen, tlen = 0, mlen = 0; + size_t llen, tlen = 0, mlen = 0, ssize; if (!lang || !*lang) return NULL; @@ -197,6 +197,10 @@ FcLangNormalize (const FcChar8 *lang) s = FcStrCopy (lang); if (!s) goto bail; + /* store the original length of 's' here to let FcMemFree know + * the correct size since we breaks 's' from now on. + */ + ssize = strlen ((const char *)s) + 1; /* from the comments in glibc: * @@ -282,6 +286,11 @@ FcLangNormalize (const FcChar8 *lang) else { result = s; + /* we'll miss the opportunity to reduce the correct size + * of the allocated memory for the string after that. + */ + FcMemFree (FC_MEM_STRING, ssize); + FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; goto bail1; } @@ -295,6 +304,11 @@ FcLangNormalize (const FcChar8 *lang) else { result = s; + /* we'll miss the opportunity to reduce the correct size + * of the allocated memory for the string after that. + */ + FcMemFree (FC_MEM_STRING, ssize); + FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; goto bail1; } @@ -312,14 +326,22 @@ FcLangNormalize (const FcChar8 *lang) else { result = s; + /* we'll miss the opportunity to reduce the correct size + * of the allocated memory for the string after that. + */ + FcMemFree (FC_MEM_STRING, ssize); + FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; } bail1: if (orig) - free (orig); + FcStrFree (orig); bail0: if (s) + { free (s); + FcMemFree (FC_MEM_STRING, ssize); + } bail: if (FcDebug () & FC_DBG_LANGSET) { diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index 037960d2f..99b59da0a 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -38,7 +38,6 @@ FcStrCopy (const FcChar8 *s) { int len; FcChar8 *r; - if (!s) return 0; len = strlen ((char *) s) + 1; @@ -1204,7 +1203,7 @@ FcStrSetAddLangs (FcStrSet *strs, const char *languages) if (normalized_lang) { FcStrSetAdd (strs, normalized_lang); - free (normalized_lang); + FcStrFree (normalized_lang); ret = FcTrue; } } @@ -1216,7 +1215,7 @@ FcStrSetAddLangs (FcStrSet *strs, const char *languages) if (normalized_lang) { FcStrSetAdd (strs, normalized_lang); - free (normalized_lang); + FcStrFree (normalized_lang); ret = FcTrue; } } diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c index 7d1d6f1ad..0c8c80561 100644..100755 --- a/fontconfig/src/fcxml.c +++ b/fontconfig/src/fcxml.c @@ -1850,7 +1850,7 @@ FcParseDir (FcConfigParse *parse) { const FcChar8 *attr; FcChar8 *data; - FcChar8 *prefix = NULL; + FcChar8 *prefix = NULL, *p; #ifdef _WIN32 FcChar8 buffer[1000]; #endif @@ -1869,13 +1869,14 @@ FcParseDir (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)data); - FcMemFree (FC_MEM_STRING, plen + 1); - prefix = realloc (prefix, plen + 1 + dlen + 1); - if (!prefix) + p = realloc (prefix, plen + 1 + dlen + 1); + if (!p) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + prefix = p; + FcMemFree (FC_MEM_STRING, plen + 1); FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); @@ -1948,7 +1949,7 @@ static void FcParseCacheDir (FcConfigParse *parse) { const FcChar8 *attr; - FcChar8 *prefix = NULL, *data; + FcChar8 *prefix = NULL, *p, *data; attr = FcConfigGetAttribute (parse, "prefix"); if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0) @@ -1964,13 +1965,15 @@ FcParseCacheDir (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)data); - FcMemFree (FC_MEM_STRING, plen + 1); - prefix = realloc (prefix, plen + 1 + dlen + 1); - if (!prefix) + p = realloc (prefix, plen + 1 + dlen + 1); + if (!p) { FcConfigMessage (parse, FcSevereError, "out of memory"); + data = prefix; goto bail; } + prefix = p; + FcMemFree (FC_MEM_STRING, plen + 1); FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); @@ -2044,7 +2047,7 @@ FcParseInclude (FcConfigParse *parse) const FcChar8 *attr; FcBool ignore_missing = FcFalse; FcBool deprecated = FcFalse; - FcChar8 *prefix = NULL; + FcChar8 *prefix = NULL, *p; s = FcStrBufDoneStatic (&parse->pstack->str); if (!s) @@ -2066,13 +2069,14 @@ FcParseInclude (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)s); - FcMemFree (FC_MEM_STRING, plen + 1); - prefix = realloc (prefix, plen + 1 + dlen + 1); - if (!prefix) + p = realloc (prefix, plen + 1 + dlen + 1); + if (!p) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + prefix = p; + FcMemFree (FC_MEM_STRING, plen + 1); FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], s, dlen); @@ -2086,8 +2090,10 @@ FcParseInclude (FcConfigParse *parse) FcChar8 *filename; filename = FcConfigFilename(s); - if ((deprecated == FcTrue) && filename) - { + if (deprecated == FcTrue && + filename != NULL && + !FcFileIsLink (filename)) + { FcConfigMessage (parse, FcSevereWarning, "reading configurations from %s is deprecated.", s); } if(filename) |