Kaydet (Commit) 7ecae3ca authored tarafından Alexey Izbyshev's avatar Alexey Izbyshev Kaydeden (comit) Benjamin Peterson

closes bpo-34468: Objects/rangeobject.c: Fix an always-false condition in range_repr() (GH-8880)

Also, propagate the error from PyNumber_AsSsize_t() because we don't care
only about OverflowError which is not reported if the second argument is NULL.

Reported by Svace static analyzer.
üst 2b824b25
...@@ -575,11 +575,11 @@ range_repr(rangeobject *r) ...@@ -575,11 +575,11 @@ range_repr(rangeobject *r)
Py_ssize_t istep; Py_ssize_t istep;
/* Check for special case values for printing. We don't always /* Check for special case values for printing. We don't always
need the step value. We don't care about errors need the step value. We don't care about overflow. */
(it means overflow), so clear the errors. */
istep = PyNumber_AsSsize_t(r->step, NULL); istep = PyNumber_AsSsize_t(r->step, NULL);
if (istep != 1 || (istep == -1 && PyErr_Occurred())) { if (istep == -1 && PyErr_Occurred()) {
PyErr_Clear(); assert(!PyErr_ExceptionMatches(PyExc_OverflowError));
return NULL;
} }
if (istep == 1) if (istep == 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment