[libeasyfc] Fix a crash when config files contains fonts not installed on the system.
Akira TAGOH
tagoh at fedoraproject.org
Mon Jan 19 09:41:41 UTC 2015
commit caff08634afed0435276fbfd92309d9cc79819fd
Author: Akira TAGOH <tagoh at redhat.com>
Date: Mon Jan 19 18:42:02 2015 +0900
Fix a crash when config files contains fonts not installed on the system.
libeasyfc-fix-crash-no-fonts.patch | 122 ++++++++++++++++++++++++++++++++++++
libeasyfc.spec | 7 ++-
2 files changed, 128 insertions(+), 1 deletions(-)
---
diff --git a/libeasyfc-fix-crash-no-fonts.patch b/libeasyfc-fix-crash-no-fonts.patch
new file mode 100644
index 0000000..3f0fb02
--- /dev/null
+++ b/libeasyfc-fix-crash-no-fonts.patch
@@ -0,0 +1,122 @@
+From 1efb1f42e00c4b8915ae3db383597776dd504c36 Mon Sep 17 00:00:00 2001
+From: Akira TAGOH <akira at tagoh.org>
+Date: Mon, 19 Jan 2015 18:32:47 +0900
+Subject: [PATCH] Fix a crash when the config contains a font not installed on
+ the system
+
+---
+ libeasyfc/ezfc-config.c | 12 +++++++++++-
+ libeasyfc/ezfc-config.h | 2 +-
+ libeasyfc/ezfc-font.c | 20 +++++++++++++++++++-
+ libeasyfc/ezfc-font.h | 3 ++-
+ 4 files changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/libeasyfc/ezfc-config.c b/libeasyfc/ezfc-config.c
+index 7e88a7c..d8bd045 100644
+--- a/libeasyfc/ezfc-config.c
++++ b/libeasyfc/ezfc-config.c
+@@ -1,7 +1,7 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /*
+ * ezfc-config.c
+- * Copyright (C) 2011-2013 Akira TAGOH
++ * Copyright (C) 2011-2015 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira at tagoh.org>
+@@ -812,10 +812,20 @@ _ezfc_config_from_xml(ezfc_config_t *config,
+ if (xmlStrcmp(node->name, (const xmlChar *)"test") == 0) {
+ attr = xmlGetProp(node, (const xmlChar *)"name");
+ if (xmlStrcmp(attr, (const xmlChar *)FC_FAMILY) == 0) {
++ gboolean b;
++
+ f = ezfc_font_new();
+ l = _ezfc_config_parse_string_node(node->children);
+ /* multiple values is not well supported */
++ /* ezfc_font_add_family may fails if a family doesn't exist in the system
++ * this is just an exception not to check the existence of fonts
++ * so that we can simply ignore that invalid entry until
++ * one installs the missing fonts again.
++ */
++ b = ezfc_font_get_check_existence(f);
++ ezfc_font_check_existence(f, FALSE);
+ ezfc_font_add_family(f, (const gchar *)l->data, &err);
++ ezfc_font_check_existence(f, b);
+ g_list_free_full(l, xmlFree);
+ }
+ xmlFree(attr);
+diff --git a/libeasyfc/ezfc-config.h b/libeasyfc/ezfc-config.h
+index d31edd1..a723b07 100644
+--- a/libeasyfc/ezfc-config.h
++++ b/libeasyfc/ezfc-config.h
+@@ -1,7 +1,7 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /*
+ * ezfc-config.h
+- * Copyright (C) 2011-2012 Akira TAGOH
++ * Copyright (C) 2011-2015 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira at tagoh.org>
+diff --git a/libeasyfc/ezfc-font.c b/libeasyfc/ezfc-font.c
+index 54dc34a..984663f 100644
+--- a/libeasyfc/ezfc-font.c
++++ b/libeasyfc/ezfc-font.c
+@@ -1,7 +1,7 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /*
+ * ezfc-font.c
+- * Copyright (C) 2011-2013 Akira TAGOH
++ * Copyright (C) 2011-2015 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira at tagoh.org>
+@@ -895,6 +895,24 @@ ezfc_font_check_existence(ezfc_font_t *font,
+ }
+
+ /**
++ * ezfc_font_get_check_existence:
++ * @font: a #ezfc_font_t
++ *
++ * Obtain a flag in @font if it's supposed to check the font existence when invoking
++ *
++ * Returns: %TRUE if it does otherwise %FALSE.
++ */
++gboolean
++ezfc_font_get_check_existence(ezfc_font_t *font)
++{
++ ezfc_font_private_t *priv = (ezfc_font_private_t *)font;
++
++ g_return_val_if_fail (font != NULL, FALSE);
++
++ return priv->check_font_existence;
++}
++
++/**
+ * ezfc_font_set_hinting:
+ * @font: a #ezfc_font_t.
+ * @flag: a boolean value.
+diff --git a/libeasyfc/ezfc-font.h b/libeasyfc/ezfc-font.h
+index a6f227c..06b25df 100644
+--- a/libeasyfc/ezfc-font.h
++++ b/libeasyfc/ezfc-font.h
+@@ -1,7 +1,7 @@
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /*
+ * ezfc-font.h
+- * Copyright (C) 2011-2013 Akira TAGOH
++ * Copyright (C) 2011-2015 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira at tagoh.org>
+@@ -112,6 +112,7 @@ gboolean ezfc_font_remove_family (ezfc_font_t
+ GError **error);
+ void ezfc_font_check_existence (ezfc_font_t *font,
+ gboolean flag);
++gboolean ezfc_font_get_check_existence (ezfc_font_t *font);
+ void ezfc_font_set_hinting (ezfc_font_t *font,
+ gboolean flag);
+ gboolean ezfc_font_get_hinting (ezfc_font_t *font);
+--
+2.1.0
+
diff --git a/libeasyfc.spec b/libeasyfc.spec
index f0a12bb..31224b0 100644
--- a/libeasyfc.spec
+++ b/libeasyfc.spec
@@ -1,12 +1,13 @@
Name: libeasyfc
Version: 0.13.0
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: Easy configuration generator interface for fontconfig
Group: System Environment/Libraries
License: LGPLv3+
URL: http://tagoh.bitbucket.org/libeasyfc/
Source0: https://bitbucket.org/tagoh/libeasyfc/downloads/%{name}-%{version}.tar.bz2
+Patch0: %{name}-fix-crash-no-fonts.patch
BuildRequires: glib2-devel gobject-introspection-devel libxml2-devel fontconfig-devel >= 2.10.92 harfbuzz-devel
BuildRequires: gettext
@@ -58,6 +59,7 @@ applications with libeasyfc-gobject.
%prep
%setup -q
+%patch0 -p1 -b .0-crash-no-fonts
%build
@@ -98,6 +100,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
%{_datadir}/gir-*/Easyfc-*.gir
%changelog
+* Mon Jan 19 2015 Akira TAGOH <tagoh at redhat.com> - 0.13.0-5
+- Fix a crash when config files contains fonts not installed on the system.
+
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.13.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
More information about the scm-commits
mailing list