summaryrefslogtreecommitdiffstats
path: root/Parser/pegen_errors.c
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-10-12 09:34:12 (GMT)
committerGitHub <noreply@github.com>2023-10-12 09:34:12 (GMT)
commitfb7843ee895ac7f6eeb58f356b1a320eea081cfc (patch)
tree2bfacf2b0e36e0d4bd4ecc00acde803ce17a9c45 /Parser/pegen_errors.c
parent3d180347ae73119bb51500efeeafdcd62bcc6f78 (diff)
downloadcpython-fb7843ee895ac7f6eeb58f356b1a320eea081cfc.zip
cpython-fb7843ee895ac7f6eeb58f356b1a320eea081cfc.tar.gz
cpython-fb7843ee895ac7f6eeb58f356b1a320eea081cfc.tar.bz2
gh-107450: Raise OverflowError when parser column offset overflows (#110754)
Diffstat (limited to 'Parser/pegen_errors.c')
-rw-r--r--Parser/pegen_errors.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c
index 2baae52..15e99e2 100644
--- a/Parser/pegen_errors.c
+++ b/Parser/pegen_errors.c
@@ -235,6 +235,12 @@ _PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *err
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 {