git repos / blockattack-game

commit 7c4b468f

sago007 · 2016-03-24 14:42
7c4b468faf0416dcd449dad16a4968243cd804de patch · browse files
parent 52d3ef2e4710d977ff83f5e5388393c73819b5be

Perform the out of bound check before using it as an index

Changed files

M source/code/main.cpp before
diff --git a/source/code/main.cpp b/source/code/main.cpp index 46619ae..b80d872 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -343,7 +343,7 @@ public:
int addBall(int x, int y,bool right,int color) {
int ballNumber = 0;
//Find a free ball
- while ((ballUsed[ballNumber])&&(ballNumber<maxNumberOfBalls)) {
+ while (ballNumber<maxNumberOfBalls && ballUsed[ballNumber]) {
ballNumber++;
}
//Could not find a free ball, return -1