Ticket #52632: 0001-inkscape-Fix-crash-on-font-name-style-being-NULL.patch

File 0001-inkscape-Fix-crash-on-font-name-style-being-NULL.patch, 5.9 KB (added by raimue (Rainer Müller), 8 years ago)
  • graphics/inkscape/Portfile

    From 02ef848f5c5bf33da394208a9ce11092242fb009 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Rainer=20M=C3=BCller?= <raimue@macports.org>
    Date: Mon, 5 Dec 2016 18:43:40 +0100
    Subject: [PATCH] inkscape: Fix crash on font name/style being NULL
    
    Closes: https://trac.macports.org/ticket/52632
    ---
     graphics/inkscape/Portfile                         |  5 +-
     .../files/patch-fontfactory-styles-crash.diff      | 98 ++++++++++++++++++++++
     2 files changed, 101 insertions(+), 2 deletions(-)
     create mode 100644 graphics/inkscape/files/patch-fontfactory-styles-crash.diff
    
    diff --git a/graphics/inkscape/Portfile b/graphics/inkscape/Portfile
    index 05a0d44..32d3734 100644
    a b PortSystem 1.0 
    55name                inkscape
    66conflicts           inkscape-devel
    77version             0.91
    8 revision            19
     8revision            20
    99license             GPL-2 LGPL-2.1
    1010maintainers         devans
    1111categories          graphics gnome
    depends_lib port:desktop-file-utils \ 
    5454                    port:py27-numpy
    5555
    5656
    57 patchfiles          patch-use-configured-perl.diff
     57patchfiles          patch-use-configured-perl.diff \
     58                    patch-fontfactory-styles-crash.diff
    5859
    5960post-patch {
    6061    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
  • new file graphics/inkscape/files/patch-fontfactory-styles-crash.diff

    diff --git a/graphics/inkscape/files/patch-fontfactory-styles-crash.diff b/graphics/inkscape/files/patch-fontfactory-styles-crash.diff
    new file mode 100644
    index 0000000..c9f45a1
    - +  
     1Upstream-Status: Pending, patch based on https://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15097 with additional null-checks for familyUIName and styleUIName
     2
     3=== modified file 'src/libnrtype/FontFactory.cpp'
     4--- src/libnrtype/FontFactory.cpp       2016-08-30 11:38:29 +0000
     5+++ src/libnrtype/FontFactory.cpp       2016-09-01 12:02:12 +0000
     6@@ -295,6 +295,7 @@
     7         const char* displayName = pango_font_family_get_name(families[currentFamily]);
     8         
     9         if (displayName == 0 || *displayName == '\0') {
     10+            std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl;
     11             continue;
     12         }
     13         sorted.push_back(std::make_pair(families[currentFamily], displayName));
     14@@ -313,6 +314,10 @@
     15     // Gather the styles for this family
     16     PangoFontFace** faces = NULL;
     17     int numFaces = 0;
     18+    if (in == NULL) {
     19+        std::cerr << "font_factory::GetUIStyles(): PangoFontFamily is NULL" << std::endl;
     20+        return ret;
     21+    }
     22     pango_font_family_list_faces(in, &faces, &numFaces);
     23 
     24     for (int currentFace = 0; currentFace < numFaces; currentFace++) {
     25@@ -322,6 +327,7 @@
     26         const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]);
     27         // std::cout << "Display Name: " << displayName << std::endl;
     28         if (displayName == NULL || *displayName == '\0') {
     29+            std::cerr << "font_factory::GetUIStyles: Missing displayName! " << std::endl;
     30             continue;
     31         }
     32
     33@@ -326,6 +332,10 @@
     34             Glib::ustring familyUIName = GetUIFamilyString(faceDescr);
     35             Glib::ustring styleUIName = GetUIStyleString(faceDescr);
     36             // std::cout << familyUIName << "  " << styleUIName << "  " << displayName << std::endl;
     37+            if (familyUIName == NULL || styleUIName == NULL) {
     38+                std::cerr << "font_factory::GetUIStyles: Missing familyUIName or styleUIName!" << std::endl;
     39+                continue;
     40+            }
     41             // Disable synthesized (faux) font faces except for CSS generic faces
     42             if (pango_font_face_is_synthesized(faces[currentFace]) ) {
     43                 if (familyUIName.compare( "sans-serif" ) != 0 &&
     44=== modified file 'src/libnrtype/font-lister.cpp'
     45--- src/libnrtype/font-lister.cpp       2016-07-14 11:17:21 +0000
     46+++ src/libnrtype/font-lister.cpp       2016-09-01 12:02:12 +0000
     47@@ -135,6 +135,8 @@
     48     if (!row[FontList.styles]) {
     49         if (row[FontList.pango_family]) {
     50             row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]);
     51+        } else {
     52+            row[FontList.styles] = default_styles;
     53         }
     54     }
     55 }
     56@@ -177,6 +179,7 @@
     57     (*treeModelIter)[FontList.family] = new_family;
     58     (*treeModelIter)[FontList.styles] = styles;
     59     (*treeModelIter)[FontList.onSystem] = false;
     60+    (*treeModelIter)[FontList.pango_family] = NULL;
     61 }
     62 
     63 void FontLister::update_font_list(SPDocument *document)
     64@@ -256,7 +259,8 @@
     65         Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend();
     66         (*treeModelIter)[FontList.family] = reinterpret_cast<const char *>(g_strdup((*i).c_str()));
     67         (*treeModelIter)[FontList.styles] = styles;
     68-        (*treeModelIter)[FontList.onSystem] = false;
     69+        (*treeModelIter)[FontList.onSystem] = false;    // false if document font
     70+        (*treeModelIter)[FontList.pango_family] = NULL; // CHECK ME (set to pango_family if on system?)
     71 
     72     }
     73 
     74@@ -993,7 +997,7 @@
     75     }
     76     catch (...)
     77     {
     78-        //std::cout << "  ERROR: can't find family: " << family << std::endl;
     79+        std::cerr << "FontLister::get_best_style_match(): can't find family: " << family << std::endl;
     80         return (target_style);
     81     }
     82 
     83@@ -1002,10 +1006,12 @@
     84 
     85     //font_description_dump( target );
     86 
     87-    if (!row[FontList.styles]) {
     88+    GList *styles = default_styles;
     89+    if (row[FontList.onSystem] && !row[FontList.styles]) {
     90         row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]);
     91+        styles = row[FontList.styles];
     92     }
     93-    GList *styles = row[FontList.styles];
     94+
     95     for (GList *l = styles; l; l = l->next) {
     96         Glib::ustring fontspec = family + ", " + ((StyleNames *)l->data)->CssName;
     97         PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str());
     98