Skip to content

Commit a4d7836

Browse files
bradlarsengvanrossum
authored andcommitted
bpo-36495: Fix two out-of-bounds array reads (GH-12641)
Research and fix by @bradlarsen.
1 parent 10654c1 commit a4d7836

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start,
14001400
goto error;
14011401
asdl_seq_SET(kwonlyargs, j++, arg);
14021402
i += 1; /* the name */
1403-
if (TYPE(CHILD(n, i)) == COMMA)
1403+
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
14041404
i += 1; /* the comma, if present */
14051405
break;
14061406
case TYPE_COMMENT:
@@ -1599,7 +1599,7 @@ ast_for_arguments(struct compiling *c, const node *n)
15991599
if (!kwarg)
16001600
return NULL;
16011601
i += 2; /* the double star and the name */
1602-
if (TYPE(CHILD(n, i)) == COMMA)
1602+
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
16031603
i += 1; /* the comma, if present */
16041604
break;
16051605
case TYPE_COMMENT:

0 commit comments

Comments
 (0)