Prevent array access out of bounds

This commit is contained in:
Jan Käberich 2021-11-01 19:15:22 +01:00
parent 1b9feeca1f
commit 8972af3f53

View File

@ -430,6 +430,8 @@ void TraceXYPlot::draw(QPainter &p)
if(i == 0) {
// only draw tick lines for primary axis
if (pref.Graphs.Color.Ticks.Background.enabled) {
if (j%2)
{
int yCoordTop = Util::Scale<double>(YAxis[i].ticks[j], YAxis[i].rangeMax, YAxis[i].rangeMin, plotAreaTop, w.height() - xAxisSpace);
int yCoordBot = Util::Scale<double>(YAxis[i].ticks[j-1], YAxis[i].rangeMax, YAxis[i].rangeMin, plotAreaTop, w.height() - xAxisSpace);
if(yCoordTop > yCoordBot) {
@ -437,8 +439,6 @@ void TraceXYPlot::draw(QPainter &p)
yCoordBot = yCoordTop;
yCoordTop = buf;
}
if (j%2)
{
p.setBrush(pref.Graphs.Color.Ticks.Background.background);
p.setPen(pref.Graphs.Color.Ticks.Background.background);
auto rect = QRect(plotAreaLeft+1, yCoordTop+1, plotAreaWidth-2, yCoordBot-yCoordTop-2);