Skip to content

Commit 21cfbd1

Browse files
Merge pull request #3 from github-samples/alert-autofix-1
Potential fix for code scanning alert no. 1: Prototype-polluting assignment
2 parents ce263a5 + 3f62515 commit 21cfbd1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

shared/src/games/tic-tac-toe.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ export class TicTacToeGame implements Game<TicTacToeGameState, TicTacToeMove> {
4141
return false;
4242
}
4343

44-
// Check if the move is within bounds
45-
if (row < 0 || row >= 3 || col < 0 || col >= 3) {
44+
// Check that row and col are numbers, integers, and not special property names
45+
if (
46+
typeof row !== 'number' ||
47+
typeof col !== 'number' ||
48+
!Number.isInteger(row) ||
49+
!Number.isInteger(col) ||
50+
row < 0 || row >= 3 ||
51+
col < 0 || col >= 3
52+
) {
4653
return false;
4754
}
4855

0 commit comments

Comments
 (0)