From f6cfcab4e53e1e9218b5d15d19f06bd4e443810b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 18 Oct 2019 11:06:23 +0200 Subject: [PATCH] [apps/shared] CurveView: add an assertion on the number of labels to avoid reading out of bound memory --- apps/shared/curve_view.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index 53f1d9b32..16d12d719 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -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) {