Skip to content

Commit

Permalink
GenericSelectTool - Avoid crash
Browse files Browse the repository at this point in the history
Don't dereference the end() iterator
  • Loading branch information
amtriathlon committed Jan 18, 2024
1 parent a4cc418 commit 573967f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Charts/GenericSelectTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,13 @@ GenericSelectTool::moved(QPointF pos)
// lower_bound to value near x
QVector<QPointF>::const_iterator i = std::lower_bound(p.begin(), p.end(), x, CompareQPointFX());

// collect them away
vals.insert(series, GPointF(i->x(), i->y(), i-p.begin()));
if (i != p.end()) {
// collect them away
vals.insert(series, GPointF(i->x(), i->y(), i-p.begin()));

// nearest x?
if (i->x() != 0 && (nearestx == -9999 || (std::fabs(i->x()-xvalue)) < std::fabs((nearestx-xvalue)))) nearestx = i->x();
// nearest x?
if (i->x() != 0 && (nearestx == -9999 || (std::fabs(i->x()-xvalue)) < std::fabs((nearestx-xvalue)))) nearestx = i->x();
}
}

}
Expand Down

0 comments on commit 573967f

Please sign in to comment.