mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-107450: Raise OverflowError when parser column offset overflows (GH-110754) (#110763)
(cherry picked from commit fb7843ee89
)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
parent
5178fb0b89
commit
c9214b90f4
2 changed files with 10 additions and 0 deletions
|
@ -224,6 +224,12 @@ _PyPegen_raise_error(Parser *p, PyObject *errtype, const char *errmsg, ...)
|
|||
col_offset = 0;
|
||||
} else {
|
||||
const char* start = p->tok->buf ? p->tok->line_start : p->tok->buf;
|
||||
if (p->tok->cur - start > INT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"Parser column offset overflow - source line is too big");
|
||||
p->error_indicator = 1;
|
||||
return NULL;
|
||||
}
|
||||
col_offset = Py_SAFE_DOWNCAST(p->tok->cur - start, intptr_t, int);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue