From: Jens Axboe Date: Wed, 21 Mar 2012 18:48:32 +0000 (+0100) Subject: graph: fix crash on alias in prio tree X-Git-Tag: gfio-0.1~71 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=4c0cd537f392e8a824d0080675f07b84c355af20 graph: fix crash on alias in prio tree Signed-off-by: Jens Axboe --- 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 &&