From 457a91c061a1658648fc155504795bf6f4c44740 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 3 Dec 2009 23:45:51 +0100 Subject: Error check in hover text code for empty graphs * grapher/GraphStyle.cxx(GraphStyleEvent::dataIndexAtPoint, GraphStyleBar::dataIndexAtPoint): check for empty graph data --- grapher/GraphStyle.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'grapher/GraphStyle.cxx') diff --git a/grapher/GraphStyle.cxx b/grapher/GraphStyle.cxx index cf3855e3..fdc8c4d6 100644 --- a/grapher/GraphStyle.cxx +++ b/grapher/GraphStyle.cxx @@ -50,7 +50,7 @@ namespace systemtap { shared_ptr > realData = dynamic_pointer_cast >(graphData); - if (!realData) + if (!realData || graphData->times.empty()) return -1; int64_t left, right; double top, bottom; @@ -58,6 +58,8 @@ namespace systemtap double t = graph->getTimeAtPoint(x); TimeListPair range = equal_range(graphData->times.begin(), graphData->times.end(), t); + if (range.first == graphData->times.end()) + return -1; size_t dataIndex = distance(graphData->times.begin(), range.first); double val = realData->data[dataIndex]; double ycoord = val * graph->_graphHeight / graphData->scale; @@ -149,7 +151,7 @@ namespace systemtap { shared_ptr > stringData = dynamic_pointer_cast >(graphData); - if (!stringData) + if (!stringData || graphData->times.empty()) return -1; int64_t left, right; double top, bottom; -- cgit