mirror of https://github.com/python/cpython
gh-95355: Check tokens[0] after allocating memory (GH-95356)
#95355 Automerge-Triggered-By: GH:pablogsal
This commit is contained in:
parent
e16d4ed590
commit
b946f529ef
|
@ -0,0 +1 @@
|
||||||
|
``_PyPegen_Parser_New`` now properly detects token memory allocation errors. Patch by Honglin Zhu.
|
|
@ -738,7 +738,7 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
|
||||||
return (Parser *) PyErr_NoMemory();
|
return (Parser *) PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
p->tokens[0] = PyMem_Calloc(1, sizeof(Token));
|
p->tokens[0] = PyMem_Calloc(1, sizeof(Token));
|
||||||
if (!p->tokens) {
|
if (!p->tokens[0]) {
|
||||||
PyMem_Free(p->tokens);
|
PyMem_Free(p->tokens);
|
||||||
PyMem_Free(p);
|
PyMem_Free(p);
|
||||||
return (Parser *) PyErr_NoMemory();
|
return (Parser *) PyErr_NoMemory();
|
||||||
|
|
Loading…
Reference in New Issue