mirror of
https://github.com/python/cpython.git
synced 2026-02-21 22:50:55 +00:00
Guard against NULL pointer arithmetic in `_PyLexer_remember_fstring_buffers` and `_PyLexer_restore_fstring_buffers`. When `start` or `multi_line_start` are NULL (uninitialized in tok_mode_stack[0]), performing `NULL - tok->buf` is undefined behavior. Add explicit NULL checks to store -1 as sentinel and restore NULL accordingly. Add test_lexer_buffer_realloc_with_null_start to test_repl.py that exercises the code path where the lexer buffer is reallocated while tok_mode_stack[0] has NULL start/multi_line_start pointers. This triggers _PyLexer_remember_fstring_buffers and verifies the NULL checks prevent undefined behavior. |
||
|---|---|---|
| .. | ||
| buffer.c | ||
| buffer.h | ||
| lexer.c | ||
| lexer.h | ||
| state.c | ||
| state.h | ||