Skip to content

Commit cf77d5a

Browse files
committed
fix: range conditions
1 parent 1f398a9 commit cf77d5a

File tree

1 file changed

+6
-6
lines changed
  • src/play/tic-tac-toe/board

1 file changed

+6
-6
lines changed

src/play/tic-tac-toe/board/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ int multiplyBoardCol(const Board *board, const size_t targetCol, const size_t st
8888

8989
size_t i;
9090

91-
if (stopAtRow < 0 || stopAtRow >= board->__rows) return 0;
92-
if (targetCol < 0 || targetCol >= board->__cols) return 0;
91+
if (stopAtRow < 0 || stopAtRow > board->__rows) return 0;
92+
if (targetCol < 0 || targetCol > board->__cols) return 0;
9393

94-
for (i = 0; i <= stopAtRow; i++) result *= board->__array2D[i][targetCol];
94+
for (i = 0; i < stopAtRow; i++) result *= board->__array2D[i][targetCol];
9595

9696
return result;
9797
}
@@ -113,10 +113,10 @@ int multiplyBoardRow(const Board *board, const size_t targetRow, const size_t st
113113

114114
size_t i;
115115

116-
if (targetRow < 0 || targetRow >= board->__rows) return 0;
117-
if (stopAtCol < 0 || stopAtCol >= board->__cols) return 0;
116+
if (targetRow < 0 || targetRow > board->__rows) return 0;
117+
if (stopAtCol < 0 || stopAtCol > board->__cols) return 0;
118118

119-
for (i = 0; i <= stopAtCol; i++) result *= board->__array2D[targetRow][i];
119+
for (i = 0; i < stopAtCol; i++) result *= board->__array2D[targetRow][i];
120120

121121
return result;
122122
}

0 commit comments

Comments
 (0)