mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-103656: Transfer f-string buffers to parser to avoid use-after-free (GH-103896)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
76632b836c
commit
9169a56fad
9 changed files with 146 additions and 66 deletions
|
@ -165,6 +165,7 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) {
|
|||
|
||||
int ret = 0;
|
||||
struct token new_token;
|
||||
new_token.metadata = NULL;
|
||||
|
||||
for (;;) {
|
||||
switch (_PyTokenizer_Get(p->tok, &new_token)) {
|
||||
|
@ -192,6 +193,7 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) {
|
|||
|
||||
|
||||
exit:
|
||||
Py_XDECREF(new_token.metadata);
|
||||
// If we're in an f-string, we want the syntax error in the expression part
|
||||
// to propagate, so that tokenizer errors (like expecting '}') that happen afterwards
|
||||
// do not swallow it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue