aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-10 08:55:36 +0100
committermarha <marha@users.sourceforge.net>2012-12-10 08:55:36 +0100
commita0124a5e8e70979d2c24ef55285da989fdad766a (patch)
tree5cea5c9804a8edf67bc7260e0851a20d21324547 /fontconfig/src
parent514b4afb64ccbf8e954270105ed5064272a2be68 (diff)
parent0328076efb5ff6e62152c09e38d0d11f7931d07b (diff)
downloadvcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.tar.gz
vcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.tar.bz2
vcxsrv-a0124a5e8e70979d2c24ef55285da989fdad766a.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libX11 mesa pixman git update 10 dec 2012 Conflicts: fontconfig/src/fcxml.c
Diffstat (limited to 'fontconfig/src')
-rw-r--r--fontconfig/src/fccfg.c2
-rw-r--r--fontconfig/src/fcdir.c14
-rw-r--r--fontconfig/src/fcinit.c16
-rw-r--r--fontconfig/src/fcint.h3
-rw-r--r--fontconfig/src/fclang.c26
-rw-r--r--fontconfig/src/fcstr.c5
-rwxr-xr-x[-rw-r--r--]fontconfig/src/fcxml.c34
7 files changed, 75 insertions, 25 deletions
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)