diff options
Diffstat (limited to 'fontconfig/src/fcxml.c')
-rwxr-xr-x[-rw-r--r--] | fontconfig/src/fcxml.c | 34 |
1 files changed, 20 insertions, 14 deletions
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) |