From 69e3963dae8dae6ec9c7e3300083d97b2c7b8b2a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 3 Oct 2013 00:13:18 +0100 Subject: [PATCH] Avoid NULL deref when deleting a node, causing empty ancestor nodes to be deleted. --- desktop/treeview.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 3bd0f6a35..02b31a670 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -1185,13 +1185,14 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n, { nserror err; struct rect r; - treeview_node *p; + bool visible; assert(tree != NULL); assert(n != NULL); assert(n->parent != NULL); - p = n->parent; + visible = n->parent->flags & TREE_NODE_EXPANDED; + r.y0 = treeview_node_y(tree, n); r.y1 = tree->root->height; @@ -1217,8 +1218,7 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n, } /* Redraw */ - if (p->flags & TREE_NODE_EXPANDED && - !(flags & TREE_OPTION_SUPPRESS_REDRAW)) { + if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) { r.x0 = 0; r.x1 = REDRAW_MAX; tree->cw_t->redraw_request(tree->cw_h, &r);