diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-10-10 10:15:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-10 10:15:12 (GMT) |
commit | 344d3a222a7864f8157773749bdd77d1c9dfc1e6 (patch) | |
tree | df48ad12a6ebd272c12be11e7463966098ad4c48 /Modules | |
parent | 0362cbf908aff2b87298f8a9422e7b368f890071 (diff) | |
download | cpython-344d3a222a7864f8157773749bdd77d1c9dfc1e6.zip cpython-344d3a222a7864f8157773749bdd77d1c9dfc1e6.tar.gz cpython-344d3a222a7864f8157773749bdd77d1c9dfc1e6.tar.bz2 |
gh-110590: Fix a bug where _sre.compile would overwrite exceptions (#110591)
TypeError would be overwritten by OverflowError
if 'code' param contained non-ints.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sre/sre.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index 07da5da..798732c 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -1508,6 +1508,9 @@ _sre_compile_impl(PyObject *module, PyObject *pattern, int flags, for (i = 0; i < n; i++) { PyObject *o = PyList_GET_ITEM(code, i); unsigned long value = PyLong_AsUnsignedLong(o); + if (value == (unsigned long)-1 && PyErr_Occurred()) { + break; + } self->code[i] = (SRE_CODE) value; if ((unsigned long) self->code[i] != value) { PyErr_SetString(PyExc_OverflowError, |