gh-105820: Fix tok_mode expression buffer in file & readline tokenizer (#105828)

This commit is contained in:
Lysandros Nikolaou 2023-06-15 18:21:24 +02:00 committed by GitHub
parent 8f10140e74
commit d382ad4915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 4 deletions

View file

@ -1039,9 +1039,6 @@ tok_readline_raw(struct tok_state *tok)
if (line == NULL) {
return 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
if (tok->fp_interactive &&
tok_concatenate_interactive_new_line(tok, line) == -1) {
return 0;
@ -1270,6 +1267,10 @@ tok_underflow_file(struct tok_state *tok) {
tok->implicit_newline = 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
ADVANCE_LINENO();
if (tok->decoding_state != STATE_NORMAL) {
if (tok->lineno > 2) {
@ -1314,6 +1315,10 @@ tok_underflow_readline(struct tok_state* tok) {
tok->implicit_newline = 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
ADVANCE_LINENO();
/* The default encoding is UTF-8, so make sure we don't have any
non-UTF-8 sequences in it. */