From 4c0cd537f392e8a824d0080675f07b84c355af20 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 21 Mar 2012 19:48:32 +0100 Subject: [PATCH] graph: fix crash on alias in prio tree Signed-off-by: Jens Axboe --- graph.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/graph.c b/graph.c index 84bc9f9b..0dae510a 100644 --- a/graph.c +++ b/graph.c @@ -707,6 +707,7 @@ static void graph_label_add_value(struct graph_label *i, void *value, double yval = gety(x); double miny = yval / TOOLTIP_DELTA; double maxy = yval * TOOLTIP_DELTA; + struct prio_tree_node *ret; INIT_PRIO_TREE_NODE(&x->node); x->node.start = miny; @@ -714,8 +715,16 @@ static void graph_label_add_value(struct graph_label *i, void *value, if (x->node.last == x->node.start) x->node.last++; - prio_tree_insert(&i->prio_tree, &x->node); - i->tooltip_count++; + /* + * If ret != &x->node, we have an alias. Since the values + * should be identical, we can drop it + */ + ret = prio_tree_insert(&i->prio_tree, &x->node); + if (ret != &x->node) { + free(x->tooltip); + x->tooltip = NULL; + } else + i->tooltip_count++; } if (i->parent->per_label_limit != -1 && -- 2.25.1