Handle invalid promoted piece (#416)
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 1 Mar 2024 14:28:21 +0000 (15:28 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 1 Mar 2024 14:28:21 +0000 (15:28 +0100)
src/position.cpp

index 023cdfa..ade4798 100644 (file)
@@ -314,7 +314,7 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
       }
 
       // Promoted shogi pieces
-      else if (token == '+' && (idx = piece_to_char().find(ss.peek())) != string::npos)
+      else if (token == '+' && (idx = piece_to_char().find(ss.peek())) != string::npos && promoted_piece_type(type_of(Piece(idx))))
       {
           ss >> token;
           put_piece(make_piece(color_of(Piece(idx)), promoted_piece_type(type_of(Piece(idx)))), sq, true, Piece(idx));