From c603e654ae99724b6e21e453d8ef895b2a915e44 Mon Sep 17 00:00:00 2001 From: Ken Vos Date: Wed, 28 Sep 2022 14:39:04 +0930 Subject: [PATCH] Fixed a crash when the ball runs out of the board. --- Board.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Board.cpp b/Board.cpp index f8e22e8..7b26f47 100644 --- a/Board.cpp +++ b/Board.cpp @@ -233,6 +233,11 @@ bool Board::step() default: std::cerr << "WARNING: The ball is arrived at (" << ball->x << ", " << ball->y << "), but this cell is given no action." << std::endl; + if ((ball->x < 0) || (ball->x >= width)) { + continuing = false; + delete ball; + ball = nullptr; + } } return continuing;