This repository was archived by the owner on Jul 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
[2.7, 3.6] Fix invalid read memory errors #38
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1372,7 +1372,7 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start, | |
goto error; | ||
asdl_seq_SET(kwonlyargs, j++, arg); | ||
i += 1; /* the name */ | ||
if (TYPE(CHILD(n, i)) == COMMA) | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA) | ||
i += 1; /* the comma, if present */ | ||
break; | ||
case TYPE_COMMENT: | ||
|
@@ -1514,7 +1514,7 @@ ast_for_arguments(struct compiling *c, const node *n) | |
return NULL; | ||
asdl_seq_SET(posargs, k++, arg); | ||
i += 1; /* the name */ | ||
if (TYPE(CHILD(n, i)) == COMMA) | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA) | ||
i += 1; /* the comma, if present */ | ||
break; | ||
case STAR: | ||
|
@@ -1530,7 +1530,7 @@ ast_for_arguments(struct compiling *c, const node *n) | |
int res = 0; | ||
i += 2; /* now follows keyword only arguments */ | ||
|
||
if (TYPE(CHILD(n, i)) == TYPE_COMMENT) { | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) { | ||
ast_error(c, CHILD(n, i), | ||
"bare * has associated type comment"); | ||
return NULL; | ||
|
@@ -1546,11 +1546,11 @@ ast_for_arguments(struct compiling *c, const node *n) | |
if (!vararg) | ||
return NULL; | ||
|
||
i += 2; /* the star and the name */ | ||
if (TYPE(CHILD(n, i)) == COMMA) | ||
i += 1; /* the comma, if present */ | ||
i += 2; /* the star and the name */ | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA) | ||
i += 1; /* the comma, if present */ | ||
|
||
if (TYPE(CHILD(n, i)) == TYPE_COMMENT) { | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gvanrossum: It seems very likely to me that this error is the cause of the |
||
vararg->type_comment = NEW_TYPE_COMMENT(CHILD(n, i)); | ||
i += 1; | ||
} | ||
|
@@ -1572,7 +1572,7 @@ ast_for_arguments(struct compiling *c, const node *n) | |
if (!kwarg) | ||
return NULL; | ||
i += 2; /* the double star and the name */ | ||
if (TYPE(CHILD(n, i)) == COMMA) | ||
if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA) | ||
i += 1; /* the comma, if present */ | ||
break; | ||
case TYPE_COMMENT: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gvanrossum: This could plausibly be the cause of
SystemError: <built-in function _parse> returned a result with an error set
with crazy line numbers. The line number here is clearly based on uninitialized memory in the spurious case.