diff options
author | marha <marha@users.sourceforge.net> | 2012-06-04 09:40:31 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-04 09:40:31 +0200 |
commit | 63918271b55923e417b14b9e7add4443582cfab3 (patch) | |
tree | 59fc1c26991bbdb97d306da11408e98f49e05607 /fontconfig | |
parent | 7d6bc8457187e6c4284201b3a6625357c4aca9b4 (diff) | |
parent | 1af6fc1b5d93e54d6674de8b5870448b29f139a7 (diff) | |
download | vcxsrv-63918271b55923e417b14b9e7add4443582cfab3.tar.gz vcxsrv-63918271b55923e417b14b9e7add4443582cfab3.tar.bz2 vcxsrv-63918271b55923e417b14b9e7add4443582cfab3.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'fontconfig')
-rw-r--r-- | fontconfig/configure.in | 2 | ||||
-rw-r--r-- | fontconfig/fc-cat/fc-cat.c | 2 | ||||
-rw-r--r-- | fontconfig/fc-list/fc-list.c | 2 | ||||
-rw-r--r-- | fontconfig/fc-match/fc-match.c | 2 | ||||
-rw-r--r-- | fontconfig/fc-pattern/fc-pattern.c | 2 | ||||
-rw-r--r-- | fontconfig/fc-query/fc-query.c | 2 | ||||
-rw-r--r-- | fontconfig/fc-scan/fc-scan.c | 2 | ||||
-rw-r--r-- | fontconfig/src/fccfg.c | 12 | ||||
-rw-r--r-- | fontconfig/src/fcformat.c | 4 | ||||
-rw-r--r-- | fontconfig/src/fcpat.c | 3 | ||||
-rw-r--r-- | fontconfig/src/fcstat.c | 56 | ||||
-rw-r--r-- | fontconfig/src/fcstr.c | 3 | ||||
-rw-r--r-- | fontconfig/src/fcxml.c | 11 |
13 files changed, 78 insertions, 25 deletions
diff --git a/fontconfig/configure.in b/fontconfig/configure.in index b2174d99b..f455cb5a5 100644 --- a/fontconfig/configure.in +++ b/fontconfig/configure.in @@ -154,6 +154,8 @@ if test "x$ac_cv_func_fstatfs" = "xyes"; then #include <sys/mount.h> #endif]) fi +AC_CHECK_MEMBERS([struct dirent.d_type],,, + [#include <dirent.h>]) # # regex # diff --git a/fontconfig/fc-cat/fc-cat.c b/fontconfig/fc-cat/fc-cat.c index b273f25d1..72912b798 100644 --- a/fontconfig/fc-cat/fc-cat.c +++ b/fontconfig/fc-cat/fc-cat.c @@ -231,7 +231,7 @@ cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBoo if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } if (verbose && !set->nfont && !ndir) diff --git a/fontconfig/fc-list/fc-list.c b/fontconfig/fc-list/fc-list.c index 0149b0c53..eb7b688c5 100644 --- a/fontconfig/fc-list/fc-list.c +++ b/fontconfig/fc-list/fc-list.c @@ -183,7 +183,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } } diff --git a/fontconfig/fc-match/fc-match.c b/fontconfig/fc-match/fc-match.c index 4642c8dee..8ae8ee9cd 100644 --- a/fontconfig/fc-match/fc-match.c +++ b/fontconfig/fc-match/fc-match.c @@ -230,7 +230,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } diff --git a/fontconfig/fc-pattern/fc-pattern.c b/fontconfig/fc-pattern/fc-pattern.c index aa51e5f39..84eb1eea1 100644 --- a/fontconfig/fc-pattern/fc-pattern.c +++ b/fontconfig/fc-pattern/fc-pattern.c @@ -176,7 +176,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/fontconfig/fc-query/fc-query.c b/fontconfig/fc-query/fc-query.c index 0680b92cf..2ed18a2c3 100644 --- a/fontconfig/fc-query/fc-query.c +++ b/fontconfig/fc-query/fc-query.c @@ -165,7 +165,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/fontconfig/fc-scan/fc-scan.c b/fontconfig/fc-scan/fc-scan.c index ebf56064e..c852e0d95 100644 --- a/fontconfig/fc-scan/fc-scan.c +++ b/fontconfig/fc-scan/fc-scan.c @@ -168,7 +168,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index 5b7249201..b45d74a23 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -1698,17 +1698,17 @@ static FcChar8 * FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) { FcChar8 *path; - int size; + int size, osize; if (!dir) dir = (FcChar8 *) ""; - size = strlen ((char *) dir) + 1 + strlen ((char *) file) + 1; + osize = 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; + size = (osize + 3) & ~3; path = malloc (size); if (!path) @@ -1729,11 +1729,12 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) #endif strcat ((char *) path, (char *) file); - FcMemAlloc (FC_MEM_STRING, size); + FcMemAlloc (FC_MEM_STRING, osize); if (access ((char *) path, R_OK) == 0) return path; FcStrFree (path); + return 0; } @@ -1853,6 +1854,7 @@ FcConfigXdgCacheHome (void) ret = malloc (len + 7 + 1); if (ret) { + FcMemAlloc (FC_MEM_STRING, len + 7 + 1); memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".cache", 7); ret[len + 7] = 0; @@ -1878,6 +1880,7 @@ FcConfigXdgConfigHome (void) ret = malloc (len + 8 + 1); if (ret) { + FcMemAlloc (FC_MEM_STRING, len + 8 + 1); memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".config", 8); ret[len + 8] = 0; @@ -1903,6 +1906,7 @@ FcConfigXdgDataHome (void) ret = malloc (len + 13 + 1); if (ret) { + FcMemAlloc (FC_MEM_STRING, len + 13 + 1); memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".local" FC_DIR_SEPARATOR_S "share", 13); ret[len + 13] = 0; diff --git a/fontconfig/src/fcformat.c b/fontconfig/src/fcformat.c index 0e63d5d7c..8eef7bb29 100644 --- a/fontconfig/src/fcformat.c +++ b/fontconfig/src/fcformat.c @@ -294,7 +294,7 @@ interpret_builtin (FcFormatContext *c, if (new_str) { FcStrBufString (buf, new_str); - free (new_str); + FcStrFree (new_str); return FcTrue; } else @@ -1014,7 +1014,7 @@ interpret_convert (FcFormatContext *c, if (new_str) { FcStrBufString (buf, new_str); - free (new_str); + FcStrFree (new_str); return FcTrue; } else diff --git a/fontconfig/src/fcpat.c b/fontconfig/src/fcpat.c index 54ec45c75..ebd6e57e2 100644 --- a/fontconfig/src/fcpat.c +++ b/fontconfig/src/fcpat.c @@ -1046,7 +1046,8 @@ FcSharedStrFree (const FcChar8 *name) { *p = b->next; size = sizeof (struct objectBucket) + strlen ((char *)name) + 1; - FcMemFree (FC_MEM_SHAREDSTR, size + sizeof (int)); + size = (size + 3) & ~3; + FcMemFree (FC_MEM_SHAREDSTR, size); free (b); } return FcTrue; diff --git a/fontconfig/src/fcstat.c b/fontconfig/src/fcstat.c index 0c15f8700..fd64d5cb3 100644 --- a/fontconfig/src/fcstat.c +++ b/fontconfig/src/fcstat.c @@ -26,6 +26,7 @@ #include "fcint.h" #include "fcarch.h" #include <dirent.h> +#include <limits.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -159,12 +160,14 @@ Adler32Finish (struct Adler32 *ctx) return ctx->a + (ctx->b << 16); } +#ifdef HAVE_STRUCT_DIRENT_D_TYPE /* dirent.d_type can be relied upon on FAT filesystem */ static FcBool FcDirChecksumScandirFilter(const struct dirent *entry) { return entry->d_type != DT_DIR; } +#endif static int FcDirChecksumScandirSorter(const struct dirent **lhs, const struct dirent **rhs) @@ -177,25 +180,62 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum) { struct Adler32 ctx; struct dirent **files; - int n; + int n, ret = 0; +#ifndef HAVE_STRUCT_DIRENT_D_TYPE + size_t len = strlen ((const char *)dir); +#endif Adler32Init (&ctx); n = scandir ((const char *)dir, &files, - &FcDirChecksumScandirFilter, - &FcDirChecksumScandirSorter); +#ifdef HAVE_STRUCT_DIRENT_D_TYPE + &FcDirChecksumScandirFilter, +#else + NULL, +#endif + &FcDirChecksumScandirSorter); if (n == -1) - return -1; + return -1; while (n--) { - Adler32Update (&ctx, files[n]->d_name, strlen(files[n]->d_name) + 1); - Adler32Update (&ctx, (char *)&files[n]->d_type, sizeof(files[n]->d_type)); - free(files[n]); + size_t dlen = strlen (files[n]->d_name); + int dtype; + +#ifdef HAVE_STRUCT_DIRENT_D_TYPE + dtype = files[n]->d_type; +#else + struct stat statb; + char f[PATH_MAX + 1]; + + memcpy (f, dir, len); + f[len] = FC_DIR_SEPARATOR; + memcpy (&f[len + 1], files[n]->d_name, dlen); + f[len + 1 + dlen] = 0; + if (lstat (f, &statb) < 0) + { + ret = -1; + goto bail; + } + if (S_ISDIR (statb.st_mode)) + goto bail; + + dtype = statb.st_mode; +#endif + Adler32Update (&ctx, files[n]->d_name, dlen + 1); + Adler32Update (&ctx, (char *)&dtype, sizeof (int)); + +#ifndef HAVE_STRUCT_DIRENT_D_TYPE + bail: +#endif + free (files[n]); } - free(files); + free (files); + if (ret == -1) + return -1; *checksum = Adler32Finish (&ctx); + return 0; } diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index f20d05e7d..e372af080 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -833,6 +833,7 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c) if (buf->allocated) { size = buf->size * 2; + FcMemFree (FC_MEM_STRBUF, buf->size); new = realloc (buf->buf, size); } else @@ -850,8 +851,6 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c) buf->failed = FcTrue; return FcFalse; } - if (buf->size) - FcMemFree (FC_MEM_STRBUF, buf->size); FcMemAlloc (FC_MEM_STRBUF, size); buf->size = size; buf->buf = new; diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c index 799352e6f..343208617 100644 --- a/fontconfig/src/fcxml.c +++ b/fontconfig/src/fcxml.c @@ -1359,6 +1359,7 @@ FcParseRange (FcConfigParse *parse) break; default: FcConfigMessage (parse, FcSevereError, "invalid element in range"); + n = 0; break; } if (count == 1) @@ -1868,12 +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) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); prefix[plen + 1 + dlen] = 0; @@ -1938,7 +1941,7 @@ FcParseDir (FcConfigParse *parse) bail: if (prefix) - free (prefix); + FcStrFree (prefix); } static void @@ -1961,12 +1964,14 @@ 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) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); prefix[plen + 1 + dlen] = 0; @@ -2057,12 +2062,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) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], s, dlen); prefix[plen + 1 + dlen] = 0; @@ -2080,7 +2087,7 @@ FcParseInclude (FcConfigParse *parse) bail: if (prefix) - free (prefix); + FcStrFree (prefix); } typedef struct _FcOpMap { |