[gnome-builder] xml-pack: protect against attributes not yet valid



commit 57a92fde5929c6f7d3d21d2f1de7d8e01fbf9858
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Fri Sep 8 17:28:36 2017 +0200

    xml-pack: protect against attributes not yet valid
    
    When collecting attributes to display in the symbol tree,
    not valid attributes report a empty name,
    which trigger an assert in get_color_tag.

 plugins/xml-pack/ide-xml-parser-generic.c |    2 +-
 plugins/xml-pack/ide-xml-parser-ui.c      |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-parser-generic.c b/plugins/xml-pack/ide-xml-parser-generic.c
index b2d75b9..feca87b 100644
--- a/plugins/xml-pack/ide-xml-parser-generic.c
+++ b/plugins/xml-pack/ide-xml-parser-generic.c
@@ -39,7 +39,7 @@ collect_attributes (IdeXmlParser  *self,
     return NULL;
 
   string = g_string_new (NULL);
-  while (l [0] != NULL)
+  while (l [0] != NULL && *l [0] != '\0')
     {
       value = ide_xml_parser_get_color_tag (self, l [0], COLOR_TAG_ATTRIBUTE, TRUE, TRUE, TRUE);
       g_string_append (string, value);
diff --git a/plugins/xml-pack/ide-xml-parser-ui.c b/plugins/xml-pack/ide-xml-parser-ui.c
index 450ca17..d7a0038 100644
--- a/plugins/xml-pack/ide-xml-parser-ui.c
+++ b/plugins/xml-pack/ide-xml-parser-ui.c
@@ -229,12 +229,16 @@ node_post_processing_collect_style_classes (IdeXmlParser      *self,
   for (gint i = 0; i < n_children; ++i)
     {
       g_autofree gchar *class_tag = NULL;
+      const gchar *name;
 
       child = IDE_XML_SYMBOL_NODE (ide_xml_symbol_node_get_nth_internal_child (node, i));
       if (ide_symbol_node_get_kind (IDE_SYMBOL_NODE (child)) == IDE_SYMBOL_UI_STYLE_CLASS)
         {
-          class_tag = ide_xml_parser_get_color_tag (self, ide_symbol_node_get_name (IDE_SYMBOL_NODE (child)),
-                                                    COLOR_TAG_STYLE_CLASS, TRUE, TRUE, TRUE);
+          name = ide_symbol_node_get_name (IDE_SYMBOL_NODE (child));
+          if (ide_str_empty0 (name))
+            continue;
+
+          class_tag = ide_xml_parser_get_color_tag (self, name, COLOR_TAG_STYLE_CLASS, TRUE, TRUE, TRUE);
           g_string_append (label, class_tag);
           g_string_append (label, " ");
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]