[gnome-builder] xml-pack: fix some coverity warnings



commit b8e30cf0eb902666f390d16518a5bfd7eda82b74
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 18 20:37:35 2017 -0700

    xml-pack: fix some coverity warnings

 plugins/xml-pack/ide-xml-path.c     |    7 ++++++-
 plugins/xml-pack/ide-xml-position.c |    6 ++++--
 plugins/xml-pack/ide-xml-sax.c      |    4 +++-
 plugins/xml-pack/ide-xml-utils.c    |    2 ++
 4 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-path.c b/plugins/xml-pack/ide-xml-path.c
index 63bb167..9a9a687 100644
--- a/plugins/xml-pack/ide-xml-path.c
+++ b/plugins/xml-pack/ide-xml-path.c
@@ -72,16 +72,21 @@ ide_xml_path_new_from_node (IdeXmlSymbolNode *node)
 {
   IdeXmlPath *self;
 
-  g_return_val_if_fail (self, NULL);
+  g_return_val_if_fail (node != NULL, NULL);
   g_return_val_if_fail (IDE_IS_XML_SYMBOL_NODE (node), NULL);
 
   self = ide_xml_path_new ();
 
+#if 0
   do
     {
       ide_xml_path_append_node (self, node);
       //node = node->parent;
     } while (node != NULL);
+#else
+  if (node != NULL)
+    ide_xml_path_append_node (self, node);
+#endif
 
   return self;
 }
diff --git a/plugins/xml-pack/ide-xml-position.c b/plugins/xml-pack/ide-xml-position.c
index 29312d3..d4cf854 100644
--- a/plugins/xml-pack/ide-xml-position.c
+++ b/plugins/xml-pack/ide-xml-position.c
@@ -242,7 +242,7 @@ ide_xml_position_print (IdeXmlPosition *self)
   const gchar *n_sibling_str;
   const gchar *kind_str;
   const gchar *detail_str;
-  IdeXmlSymbolNode *parent_node;
+  IdeXmlSymbolNode *parent_node = NULL;
   gint n_children;
 
   p_sibling_str = (self->previous_sibling_node == NULL) ?
@@ -256,7 +256,9 @@ ide_xml_position_print (IdeXmlPosition *self)
   kind_str = ide_xml_position_kind_get_str (self->kind);
   detail_str = ide_xml_position_detail_get_str (self->detail);
 
-  parent_node = ide_xml_symbol_node_get_parent (self->node);
+  if (self->node != NULL)
+    parent_node = ide_xml_symbol_node_get_parent (self->node);
+
   printf ("POSITION: parent: %s node: %s kind:%s detail:'%s'\n \
            prefix:'%s' detail name:'%s' detail value:'%s' quote:'%c'\n",
           (parent_node != NULL) ? ide_xml_symbol_node_get_element_name (parent_node) : "none",
diff --git a/plugins/xml-pack/ide-xml-sax.c b/plugins/xml-pack/ide-xml-sax.c
index 1b9e1d6..ba2564f 100644
--- a/plugins/xml-pack/ide-xml-sax.c
+++ b/plugins/xml-pack/ide-xml-sax.c
@@ -194,7 +194,7 @@ get_tag_location (IdeXmlSax    *self,
   const gchar *current;
   const gchar *end_current;
   const gchar *line_start;
-  const gchar *end_line_start;
+  const gchar *end_line_start = NULL;
   gint start_line_number;
   gint end_line_number;
   gint size_offset = 1;
@@ -313,6 +313,8 @@ next:
       line_start = g_utf8_prev_char (line_start);
     }
 
+  g_assert (end_line_start != NULL);
+
   *line = start_line_number;
   *line_offset = (current - line_start) + 1;
   *end_line_offset = (end_current - end_line_start) + 1;
diff --git a/plugins/xml-pack/ide-xml-utils.c b/plugins/xml-pack/ide-xml-utils.c
index b76ad6d..5ab8e03 100644
--- a/plugins/xml-pack/ide-xml-utils.c
+++ b/plugins/xml-pack/ide-xml-utils.c
@@ -98,6 +98,8 @@ jump_to_next_attribute (const gchar **cursor)
   if (skip_whitespaces (&p))
     has_spaces = TRUE;
 
+  ch = g_utf8_get_char (p);
+
   if (ch == '"' || ch == '\'')
     {
       term = ch;


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