Skip to content

Commit d43b0e5

Browse files
committed
handle crash when terminating cli match with SIGINT (#764)
1 parent 87901b8 commit d43b0e5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

projects/lib/src/chessplayer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,13 @@ void ChessPlayer::claimResult(const Chess::Result& result)
260260

261261
void ChessPlayer::forfeit(Chess::Result::Type type, const QString& description)
262262
{
263+
// If the board is gone, it means the game already ended and has an
264+
// appropriate result.
265+
if (m_board == nullptr)
266+
return;
267+
263268
Chess::Side opp = m_side.opposite();
264-
if (!opp.isNull() && !board()->winPossible(opp))
269+
if (!opp.isNull() && !m_board->winPossible(opp))
265270
m_side = Chess::Side::NoSide;
266271

267272
if (m_side.isNull())

0 commit comments

Comments
 (0)