From 4a191dc3c0279b2540c456b00ca036c64460be73 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Wed, 2 Mar 2022 20:41:47 +0900 Subject: [PATCH 1/3] Fix a memory leak. Resolves: rhbz#1914716 --- fontconfig-1914716.patch | 44 ++++++++++++++++++++++++++++++++++++++++ fontconfig.spec | 7 ++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 fontconfig-1914716.patch diff --git a/fontconfig-1914716.patch b/fontconfig-1914716.patch new file mode 100644 index 0000000..4dee6d1 --- /dev/null +++ b/fontconfig-1914716.patch @@ -0,0 +1,44 @@ +From 57032f489b2cbe98c8e7927f4c18738869831f41 Mon Sep 17 00:00:00 2001 +From: Akira TAGOH +Date: Wed, 25 Aug 2021 15:52:53 +0900 +Subject: [PATCH] Fix a memory leak when trying to open a non-existing file + +https://bugzilla.redhat.com/show_bug.cgi?id=1914716 +--- + src/fccache.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/fccache.c b/src/fccache.c +index ae3b9e3..d8ffe09 100644 +--- a/src/fccache.c ++++ b/src/fccache.c +@@ -1111,7 +1111,7 @@ FcCache * + FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat) + { + int fd; +- FcCache *cache; ++ FcCache *cache = NULL; + struct stat my_file_stat; + FcConfig *config; + +@@ -1121,11 +1121,13 @@ FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat) + if (!config) + return NULL; + fd = FcDirCacheOpenFile (cache_file, file_stat); +- if (fd < 0) +- return NULL; +- cache = FcDirCacheMapFd (config, fd, file_stat, NULL); ++ if (fd >= 0) ++ { ++ cache = FcDirCacheMapFd (config, fd, file_stat, NULL); ++ close (fd); ++ } + FcConfigDestroy (config); +- close (fd); ++ + return cache; + } + +-- +2.35.1 + diff --git a/fontconfig.spec b/fontconfig.spec index b54f73c..0bb252b 100644 --- a/fontconfig.spec +++ b/fontconfig.spec @@ -5,7 +5,7 @@ Summary: Font configuration and customization library Name: fontconfig Version: 2.13.94 -Release: 3%{?dist} +Release: 4%{?dist} # src/ftglue.[ch] is in Public Domain # src/fccache.c contains Public Domain code # fc-case/CaseFolding.txt is in the UCD @@ -22,6 +22,7 @@ Patch4: %{name}-drop-lang-from-pkgkit-format.patch Patch5: %{name}-disable-network-required-test.patch Patch6: %{name}-score-fix.patch Patch7: %{name}-lcdfilter.patch +Patch8: %{name}-1914716.patch BuildRequires: libxml2-devel BuildRequires: freetype-devel >= %{freetype_version} @@ -189,6 +190,10 @@ fi %doc fontconfig-devel.txt fontconfig-devel %changelog +* Wed Mar 2 2022 Akira TAGOH - 2.13.94-4 +- Fix a memory leak. + Resolves: rhbz#1914716 + * Wed Jul 21 2021 Fedora Release Engineering - 2.13.94-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild From 1e108c811cf77848685e4ef6f8582e0169966992 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Thu, 3 Mar 2022 17:56:12 +0900 Subject: [PATCH 2/3] Fix the matching function for postscriptname property. Resolves: rhbz#1946871 --- fontconfig.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fontconfig.spec b/fontconfig.spec index 0bb252b..245ac44 100644 --- a/fontconfig.spec +++ b/fontconfig.spec @@ -5,7 +5,7 @@ Summary: Font configuration and customization library Name: fontconfig Version: 2.13.94 -Release: 4%{?dist} +Release: 5%{?dist} # src/ftglue.[ch] is in Public Domain # src/fccache.c contains Public Domain code # fc-case/CaseFolding.txt is in the UCD @@ -23,6 +23,7 @@ Patch5: %{name}-disable-network-required-test.patch Patch6: %{name}-score-fix.patch Patch7: %{name}-lcdfilter.patch Patch8: %{name}-1914716.patch +Patch9: %{name}-1946871.patch BuildRequires: libxml2-devel BuildRequires: freetype-devel >= %{freetype_version} @@ -190,6 +191,10 @@ fi %doc fontconfig-devel.txt fontconfig-devel %changelog +* Thu Mar 3 2022 Akira TAGOH - 2.13.94-5 +- Fix the matching function for postscriptname property. + Resolves: rhbz#1946871 + * Wed Mar 2 2022 Akira TAGOH - 2.13.94-4 - Fix a memory leak. Resolves: rhbz#1914716 From 6981f331cf0917e5abb111f8919166eb88f50b48 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Thu, 3 Mar 2022 18:02:49 +0900 Subject: [PATCH 3/3] Fix the matching function for postscriptname property. Resolves: rhbz#1946871 --- fontconfig-1946871.patch | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 fontconfig-1946871.patch diff --git a/fontconfig-1946871.patch b/fontconfig-1946871.patch new file mode 100644 index 0000000..04a8e63 --- /dev/null +++ b/fontconfig-1946871.patch @@ -0,0 +1,48 @@ +From 2d17232a45c55cdb8d082a3bcf13d423928fcd5e Mon Sep 17 00:00:00 2001 +From: Akira TAGOH +Date: Fri, 8 Oct 2021 18:29:48 +0900 +Subject: [PATCH] Fix score estimation for postscriptname + +Before this fix: +$ fc-match :postscriptname=LiberationSans +LiberationSansNarrow.ttf: "Liberation Sans Narrow" "Regular" + +After this fix: +$ fc-match :postscriptname=LiberationSans +LiberationSans-Regular.ttf: "Liberation Sans" "Regular" + +See https://bugzilla.redhat.com/show_bug.cgi?id=1946871 +--- + src/fcmatch.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/fcmatch.c b/src/fcmatch.c +index 80d5687..cf0876c 100644 +--- a/src/fcmatch.c ++++ b/src/fcmatch.c +@@ -86,7 +86,7 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue) + const FcChar8 *v1_string = FcValueString (v1); + const FcChar8 *v2_string = FcValueString (v2); + int n; +- size_t len; ++ size_t len1, len2, mlen; + + *bestValue = FcValueCanonicalize (v2); + +@@ -95,9 +95,11 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue) + return 1.0; + + n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -"); +- len = strlen ((const char *)v1_string); ++ len1 = strlen ((const char *)v1_string); ++ len2 = strlen ((const char *)v2_string); ++ mlen = FC_MAX (len1, len2); + +- return (double)(len - n) / (double)len; ++ return (double)(mlen - n) / (double)mlen; + } + + static double +-- +2.35.1 +