JAL-2068 avoid ArrayIndexOutOfBounds when consensus accessed before calculation has...
[jalview.git] / src / jalview / gui / SequenceRenderer.java
index aec61b5..7928a89 100755 (executable)
@@ -455,8 +455,10 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
                     .getCharAt(position) : av.getAlignment().getSeqrep()
                     .getCharAt(position)))
             : (currentGroup != null && currentGroup.getConsensus() != null
-                    && position >= currentGroup.getStartRes() && position <= currentGroup
-                    .getEndRes()) ? currentGroup.getConsensus().annotations[position].displayCharacter
+                    && position >= currentGroup.getStartRes()
+                    && position <= currentGroup.getEndRes() && currentGroup
+                    .getConsensus().annotations.length > position) ? currentGroup
+                    .getConsensus().annotations[position].displayCharacter
                     .charAt(0)
                     : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter
                             .charAt(0);