Skip to content

Commit d486bb7

Browse files
committed
shared/runtime/pyexec: Fix UBSan error in pyexec_stdin().
Use mp_lexer_new_from_fd() instead of mp_reader_new_file_from_fd() to match the original execute_from_lexer() behavior. This avoids undefined behavior detected by UBSan where bool close_fd contained non-bool values. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent a4294c2 commit d486bb7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

shared/runtime/pyexec.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,8 @@ int pyexec_str_single(const char *str, bool allow_keyboard_interrupt) {
766766
}
767767

768768
int pyexec_stdin(void) {
769-
mp_reader_t reader;
770-
mp_reader_new_file_from_fd(&reader, 0, false);
771-
mp_uint_t exec_flags = EXEC_FLAG_SOURCE_IS_READER;
772-
return parse_compile_execute(&reader, MP_PARSE_FILE_INPUT, exec_flags, NULL);
769+
mp_lexer_t *lex = mp_lexer_new_from_fd(MP_QSTR__lt_stdin_gt_, 0, false);
770+
return parse_compile_execute(lex, MP_PARSE_FILE_INPUT, 0, NULL);
773771
}
774772
#endif
775773

0 commit comments

Comments
 (0)