8000 [3.11] gh-95355: Check tokens[0] after allocating memory (GH-95356) by miss-islington · Pull Request #95367 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-95355: Check tokens[0] after allocating memory (GH-95356) #95367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
10000
Failed to load files.
Loading
Diff view
Diff view
gh-95355: Check tokens[0] after allocating memory (GH-95356)
GH-95355

Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit b946f52)

Co-authored-by: Honglin Zhu <zhuhonglin.zhl@alibaba-inc.com>
  • Loading branch information
imzhuhl authored and miss-islington committed Jul 28, 2022
commit c2fb6cac8476a6ba88226c4195a457d08b5048b2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``_PyPegen_Parser_New`` now properly detects token memory allocation errors. Patch by Honglin Zhu.
2 changes: 1 addition & 1 deletion Parser/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
return (Parser *) PyErr_NoMemory();
}
p->tokens[0] = PyMem_Calloc(1, sizeof(Token));
if (!p->tokens) {
if (!p->tokens[0]) {
PyMem_Free(p->tokens);
PyMem_Free(p);
return (Parser *) PyErr_NoMemory();
Expand Down
0