From 260b2075e212380c0c4146c10b03a1b024d82e3e Mon Sep 17 00:00:00 2001 From: Daniel Schramm <xschramm@fi.muni.cz> Date: Fri, 17 Sep 2021 17:16:55 +0200 Subject: [PATCH] Index-in-bounds check added --- .../cz/fidentis/analyst/distance/DistanceAction.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java index b26cc653..f4f1d565 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/distance/DistanceAction.java @@ -3,6 +3,7 @@ package cz.fidentis.analyst.distance; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.LoadedActionEvent; import cz.fidentis.analyst.core.ControlPanelAction; +import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePointType; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.scene.DrawableFeaturePoints; @@ -203,8 +204,12 @@ public class DistanceAction extends ControlPanelAction { } private FeaturePointType getTypeOfFeaturePoint(int index) { - return getSecondaryFeaturePoints().getFeaturePoints() - .get(index) + final List<FeaturePoint> featurePoints = getSecondaryFeaturePoints().getFeaturePoints(); + if (index < 0 || index >= featurePoints.size()) { + return null; + } + + return featurePoints.get(index) .getFeaturePointType(); } } -- GitLab