From 8fdfdede445a934acaa6f7fa3fa7376112f0f6c7 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Mon, 18 May 2020 21:50:36 +0200 Subject: [PATCH] Fix potential crash if an engine reports an invalid currmove Could cause an ArrayIndexOutOfBoundsException: at org.petero.droidfish.gamelogic.Position.getPiece (Position.java:153) at org.petero.droidfish.gamelogic.MoveGen.pseudoLegalMoves (MoveGen.java:109) at org.petero.droidfish.gamelogic.MoveGen.legalMoves (MoveGen.java:32) at org.petero.droidfish.gamelogic.TextIO.moveToString (TextIO.java:429) at org.petero.droidfish.gamelogic.TextIO.moveToString (TextIO.java:339) at org.petero.droidfish.gamelogic.DroidChessController$SearchListener.notifyCurrMove (DroidChessController.java:826) --- .../org/petero/droidfish/gamelogic/DroidChessController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DroidFishApp/src/main/java/org/petero/droidfish/gamelogic/DroidChessController.java b/DroidFishApp/src/main/java/org/petero/droidfish/gamelogic/DroidChessController.java index 89c126b..4db8cd2 100644 --- a/DroidFishApp/src/main/java/org/petero/droidfish/gamelogic/DroidChessController.java +++ b/DroidFishApp/src/main/java/org/petero/droidfish/gamelogic/DroidChessController.java @@ -838,8 +838,11 @@ public class DroidChessController { @Override public void notifyCurrMove(int id, Position pos, Move m, int moveNr) { + Position tmpPos = new Position(pos); + if (!TextIO.isValid(tmpPos, m)) + m = new Move(0, 0, 0); currMove = m; - currMoveStr = TextIO.moveToString(pos, m, false, localPt()); + currMoveStr = TextIO.moveToString(tmpPos, m, false, localPt()); currMoveNr = moveNr; setSearchInfo(id); }