diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-07-13 10:40:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-13 10:40:44 (GMT) |
commit | 18015451d0e3f4d155d56f70faf9b76ce5b7ad79 (patch) | |
tree | 910432b2dbd6c372f70e340d456612909f45f14c /Python | |
parent | 0759cecd9d945dfbac2226febaba51f41195555c (diff) | |
download | cpython-18015451d0e3f4d155d56f70faf9b76ce5b7ad79.zip cpython-18015451d0e3f4d155d56f70faf9b76ce5b7ad79.tar.gz cpython-18015451d0e3f4d155d56f70faf9b76ce5b7ad79.tar.bz2 |
gh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154)
* The result has type Py_ssize_t, not intptr_t.
* Type cast between unsigned and signdet integer types should be explicit.
* Downcasting should be explicit.
* Fix integer overflow check in sum().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index a5b45e3..3f7bf4d 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2644,8 +2644,8 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) b = PyLong_AsLongAndOverflow(item, &overflow); } if (overflow == 0 && - (i_result >= 0 ? (b <= LONG_MAX - i_result) - : (b >= LONG_MIN - i_result))) + (i_result >= 0 ? (b <= PY_SSIZE_T_MAX - i_result) + : (b >= PY_SSIZE_T_MIN - i_result))) { i_result += b; Py_DECREF(item); |