[libdazzle] tree-node: try harder to find a tree



commit e3794b42b5ccec69c1807ce11d3db88eb3c963f1
Author: Christian Hergert <chergert redhat com>
Date:   Mon Dec 4 17:49:47 2017 -0800

    tree-node: try harder to find a tree
    
    In case we somehow get into a situation with a bad tree pointer,
    try harder by walking to the root of the nodes.
    
    This is mostly just defensive, as it should not be likely to
    happen.

 src/tree/dzl-tree-node.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/tree/dzl-tree-node.c b/src/tree/dzl-tree-node.c
index ea9d064..a531672 100644
--- a/src/tree/dzl-tree-node.c
+++ b/src/tree/dzl-tree-node.c
@@ -98,7 +98,14 @@ dzl_tree_node_get_tree (DzlTreeNode *node)
 {
   g_return_val_if_fail (DZL_IS_TREE_NODE (node), NULL);
 
-  return node->tree;
+  while (node != NULL)
+    {
+      if (node->tree != NULL)
+        return node->tree;
+      node = node->parent;
+    }
+
+  return NULL;
 }
 
 /**


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