[apps/shared] CurveView: add an assertion on the number of labels to

avoid reading out of bound memory
This commit is contained in:
Émilie Feral
2019-10-18 11:06:23 +02:00
committed by LeaNumworks
parent 2ff0b789f9
commit f6cfcab4e5

View File

@@ -167,7 +167,9 @@ int CurveView::numberOfLabels(Axis axis) const {
float labelStep = 2.0f * gridUnit(axis);
float minLabel = std::ceil(min(axis)/labelStep);
float maxLabel = std::floor(max(axis)/labelStep);
return maxLabel - minLabel + 1;
int numberOfLabels = maxLabel - minLabel + 1;
assert(numberOfLabels <= (axis == Axis::Horizontal ? k_maxNumberOfXLabels : k_maxNumberOfYLabels));
return numberOfLabels;
}
void CurveView::computeLabels(Axis axis) {