@@ -5,7 +5,7 @@ Contains ad hoc patches for cross building.
55From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
66From: Kleis Auke Wolthuizen <
[email protected] >
77Date: Thu, 13 Feb 2020 16:00:00 +0100
8- Subject: [PATCH 1/1 ] Ignore an error when loading the default config file
8+ Subject: [PATCH 1/4 ] Ignore an error when loading the default config file
99
1010This error can be safely ignored since Windows doesn't ship
1111a fonts.conf file. It can also be disabled by setting the
@@ -26,3 +26,166 @@ index 1111111..2222222 100644
2626 FcStrBufDestroy (&reason);
2727 return FcFalse;
2828 }
29+
30+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
31+ From: Akira TAGOH <
[email protected] >
32+ Date: Wed, 25 Aug 2021 15:52:53 +0900
33+ Subject: [PATCH 2/4] Fix a memory leak when trying to open a non-existing file
34+
35+ https://bugzilla.redhat.com/show_bug.cgi?id=1914716
36+
37+ Upstream-Status: Accepted [https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/57032f489b2cbe98c8e7927f4c18738869831f41]
38+
39+ diff --git a/src/fccache.c b/src/fccache.c
40+ index 1111111..2222222 100644
41+ --- a/src/fccache.c
42+ +++ b/src/fccache.c
43+ @@ -1111,7 +1111,7 @@ FcCache *
44+ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
45+ {
46+ int fd;
47+ - FcCache *cache;
48+ + FcCache *cache = NULL;
49+ struct stat my_file_stat;
50+ FcConfig *config;
51+
52+ @@ -1121,11 +1121,13 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
53+ if (!config)
54+ return NULL;
55+ fd = FcDirCacheOpenFile (cache_file, file_stat);
56+ - if (fd < 0)
57+ - return NULL;
58+ - cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
59+ + if (fd >= 0)
60+ + {
61+ + cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
62+ + close (fd);
63+ + }
64+ FcConfigDestroy (config);
65+ - close (fd);
66+ +
67+ return cache;
68+ }
69+
70+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
71+ From: Ben Wagner <
[email protected] >
72+ Date: Tue, 31 Aug 2021 12:47:48 -0400
73+ Subject: [PATCH 3/4] Free local FcCache lock on contention
74+
75+ If two threads attempt to create the FcCache lock in lock_cache at the
76+ same time, both threads may create and initialize a local FcMutex. One
77+ thread will atomically make cache_lock point to its FcMutex. The other
78+ thread currently calls FcMutexFinish on the local lock, but does not
79+ free it. Change this behavior to free the unused lock.
80+
81+ Found with test/test-pthread on an LeakSanitizer enabled build.
82+
83+ Upstream-Status: Accepted [https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/efc71a3c132be05461ffc872e70390d61f27bc7e]
84+
85+ diff --git a/src/fccache.c b/src/fccache.c
86+ index 1111111..2222222 100644
87+ --- a/src/fccache.c
88+ +++ b/src/fccache.c
89+ @@ -495,6 +495,7 @@ retry:
90+ FcMutexInit (lock);
91+ if (!fc_atomic_ptr_cmpexch (&cache_lock, NULL, lock)) {
92+ FcMutexFinish (lock);
93+ + free (lock);
94+ goto retry;
95+ }
96+
97+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
98+ From: Akira TAGOH <
[email protected] >
99+ Date: Mon, 31 Jan 2022 19:03:29 +0900
100+ Subject: [PATCH 4/4] Fix possible memory leaks in FcPatternObjectAddWithBinding
101+
102+ Reported by Ruth Ivimey-Cook
103+
104+ Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/302
105+
106+ Upstream-Status: Accepted [https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/875878efb7ddd57303b75320b4ea10ee2b9cf370]
107+
108+ diff --git a/src/fcpat.c b/src/fcpat.c
109+ index 1111111..2222222 100644
110+ --- a/src/fcpat.c
111+ +++ b/src/fcpat.c
112+ @@ -142,27 +142,7 @@ FcValueListDestroy (FcValueListPtr l)
113+ FcValueListPtr next;
114+ for (; l; l = next)
115+ {
116+ - switch ((int) l->value.type) {
117+ - case FcTypeString:
118+ - FcFree (l->value.u.s);
119+ - break;
120+ - case FcTypeMatrix:
121+ - FcMatrixFree ((FcMatrix *)l->value.u.m);
122+ - break;
123+ - case FcTypeCharSet:
124+ - FcCharSetDestroy
125+ - ((FcCharSet *) (l->value.u.c));
126+ - break;
127+ - case FcTypeLangSet:
128+ - FcLangSetDestroy
129+ - ((FcLangSet *) (l->value.u.l));
130+ - break;
131+ - case FcTypeRange:
132+ - FcRangeDestroy ((FcRange *) (l->value.u.r));
133+ - break;
134+ - default:
135+ - break;
136+ - }
137+ + FcValueDestroy (l->value);
138+ next = FcValueListNext(l);
139+ free(l);
140+ }
141+ @@ -708,30 +688,29 @@ FcPatternObjectAddWithBinding (FcPattern *p,
142+ if (!new)
143+ goto bail0;
144+
145+ - value = FcValueSave (value);
146+ - if (value.type == FcTypeVoid)
147+ + new->value = FcValueSave (value);
148+ + new->binding = binding;
149+ + new->next = NULL;
150+ +
151+ + if (new->value.type == FcTypeVoid)
152+ goto bail1;
153+
154+ /*
155+ * Make sure the stored type is valid for built-in objects
156+ */
157+ - if (!FcObjectValidType (object, value.type))
158+ + if (!FcObjectValidType (object, new->value.type))
159+ {
160+ fprintf (stderr,
161+ "Fontconfig warning: FcPattern object %s does not accept value",
162+ FcObjectName (object));
163+ - FcValuePrintFile (stderr, value);
164+ + FcValuePrintFile (stderr, new->value);
165+ fprintf (stderr, "\n");
166+ goto bail1;
167+ }
168+
169+ - new->value = value;
170+ - new->binding = binding;
171+ - new->next = NULL;
172+ -
173+ e = FcPatternObjectInsertElt (p, object);
174+ if (!e)
175+ - goto bail2;
176+ + goto bail1;
177+
178+ if (append)
179+ {
180+ @@ -747,10 +726,8 @@ FcPatternObjectAddWithBinding (FcPattern *p,
181+
182+ return FcTrue;
183+
184+ - bail2:
185+ - FcValueDestroy (value);
186+ bail1:
187+ - free (new);
188+ + FcValueListDestroy (new);
189+ bail0:
190+ return FcFalse;
191+ }
0 commit comments