mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.9] bpo-45820: Fix a segfault when the parser fails without reading any input (GH-29580) (GH-29584)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
0ef308a289
commit
00ee14e814
3 changed files with 12 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -136,5 +136,7 @@ Tools/ssl/win32
|
|||
!/Python/
|
||||
|
||||
# Artifacts generated by 3.11 lying around when switching branches:
|
||||
/_bootstrap_python
|
||||
/Programs/_freeze_module
|
||||
/Python/deepfreeze/
|
||||
/Python/frozen_modules/
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Fix a segfault when the parser fails without reading any input. Patch by
|
||||
Pablo Galindo
|
||||
|
|
@ -364,6 +364,14 @@ tokenizer_error(Parser *p)
|
|||
void *
|
||||
_PyPegen_raise_error(Parser *p, PyObject *errtype, const char *errmsg, ...)
|
||||
{
|
||||
if (p->fill == 0) {
|
||||
va_list va;
|
||||
va_start(va, errmsg);
|
||||
_PyPegen_raise_error_known_location(p, errtype, 0, 0, errmsg, va);
|
||||
va_end(va);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Token *t = p->known_err_token != NULL ? p->known_err_token : p->tokens[p->fill - 1];
|
||||
Py_ssize_t col_offset;
|
||||
if (t->col_offset == -1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue