diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2023-04-27 01:33:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 01:33:31 (GMT) |
commit | 9169a56fad246364fd3224306e72e0d0725c35aa (patch) | |
tree | 2a79d19be8d01fdd08ff5b54080ebfee72ae089d /Parser/pegen_errors.c | |
parent | 76632b836cf81a95301f4eb1fa43682e8d9ffa67 (diff) | |
download | cpython-9169a56fad246364fd3224306e72e0d0725c35aa.zip cpython-9169a56fad246364fd3224306e72e0d0725c35aa.tar.gz cpython-9169a56fad246364fd3224306e72e0d0725c35aa.tar.bz2 |
gh-103656: Transfer f-string buffers to parser to avoid use-after-free (GH-103896)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Parser/pegen_errors.c')
-rw-r--r-- | Parser/pegen_errors.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index e26bad2..1f227da 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -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. |