Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.

Commit dc317ac

Browse files
wictorygvanrossum
authored andcommitted
Fix two out-of-bounds array reads (#99)
The patch is taken from a commit to the CPython repo with the message: bpo-36495: Fix two out-of-bounds array reads (GH-12641) Research and fix by @bradlarsen.
1 parent 0de4de6 commit dc317ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ast3/Python/ast.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start,
14451445
goto error;
14461446
asdl_seq_SET(kwonlyargs, j++, arg);
14471447
i += 1; /* the name */
1448-
if (TYPE(CHILD(n, i)) == COMMA)
1448+
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
14491449
i += 1; /* the comma, if present */
14501450
break;
14511451
case TYPE_COMMENT:
@@ -1644,7 +1644,7 @@ ast_for_arguments(struct compiling *c, const node *n)
16441644
if (!kwarg)
16451645
return NULL;
16461646
i += 2; /* the double star and the name */
1647-
if (TYPE(CHILD(n, i)) == COMMA)
1647+
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
16481648
i += 1; /* the comma, if present */
16491649
break;
16501650
case TYPE_COMMENT:

0 commit comments

Comments
 (0)