[gnome-builder] xml pack: fix possible use of a NULL pointer
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] xml pack: fix possible use of a NULL pointer
- Date: Mon, 14 Aug 2017 21:20:19 +0000 (UTC)
commit 7a44366cec91fbd0e856f1eaa818eacb15b8fd2a
Author: Sebastien Lafargue <slafargue gnome org>
Date: Mon Aug 14 23:17:52 2017 +0200
xml pack: fix possible use of a NULL pointer
plugins/xml-pack/ide-xml-position.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-position.c b/plugins/xml-pack/ide-xml-position.c
index d4cf854..e206c31 100644
--- a/plugins/xml-pack/ide-xml-position.c
+++ b/plugins/xml-pack/ide-xml-position.c
@@ -273,23 +273,26 @@ ide_xml_position_print (IdeXmlPosition *self)
if (self->child_pos != -1)
{
printf (" (between %s and %s)", p_sibling_str, n_sibling_str);
- n_children = ide_xml_symbol_node_get_n_direct_children (self->node);
- if (self->child_pos == 0)
+ if (self->node != NULL)
{
- if (n_children == 1)
- printf (" pos: |0\n");
- else
- printf (" pos: |0..%d\n", n_children - 1);
- }
- else if (self->child_pos == n_children)
- {
- if (n_children == 1)
- printf (" pos: 0|\n");
+ n_children = ide_xml_symbol_node_get_n_direct_children (self->node);
+ if (self->child_pos == 0)
+ {
+ if (n_children == 1)
+ printf (" pos: |0\n");
+ else
+ printf (" pos: |0..%d\n", n_children - 1);
+ }
+ else if (self->child_pos == n_children)
+ {
+ if (n_children == 1)
+ printf (" pos: 0|\n");
+ else
+ printf (" pos: 0..%d|\n", n_children - 1);
+ }
else
- printf (" pos: 0..%d|\n", n_children - 1);
+ printf (" pos: %d|%d\n", self->child_pos - 1, self->child_pos);
}
- else
- printf (" pos: %d|%d\n", self->child_pos - 1, self->child_pos);
}
else if (self->child_node != NULL)
printf (" child node:%s\n", ide_xml_symbol_node_get_element_name (self->child_node));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]