Fix crash when generating castling move