Commit ea7f75d4 authored by Tim Peters's avatar Tim Peters

slot_nb_nonzero(): Another leak uncovered by the sandbox datetime

tests.  I found the logic too confusing to follow here, so rewrote more
than was likely absolutely necessary.

Bugfix candidate.
parent 27cae1f7
......@@ -3734,30 +3734,29 @@ SLOT0(slot_nb_absolute, "__abs__")
static int
slot_nb_nonzero(PyObject *self)
{
PyObject *func, *res, *args;
PyObject *func, *args;
static PyObject *nonzero_str, *len_str;
int result = -1;
func = lookup_maybe(self, "__nonzero__", &nonzero_str);
if (func == NULL) {
if (PyErr_Occurred())
return -1;
func = lookup_maybe(self, "__len__", &len_str);
if (func == NULL) {
if (PyErr_Occurred())
return -1;
else
return 1;
}
if (func == NULL)
return PyErr_Occurred() ? -1 : 1;
}
args = res = PyTuple_New(0);
args = PyTuple_New(0);
if (args != NULL) {
res = PyObject_Call(func, args, NULL);
PyObject *temp = PyObject_Call(func, args, NULL);
Py_DECREF(args);
if (temp != NULL) {
result = PyObject_IsTrue(temp);
Py_DECREF(temp);
}
}
Py_DECREF(func);
if (res == NULL)
return -1;
return PyObject_IsTrue(res);
return result;
}
SLOT0(slot_nb_invert, "__invert__")
......
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