summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-03-23 05:35:36 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-03-23 05:35:36 (GMT)
commitbf9b24464e11d9db2980c018f4d67b50b3573903 (patch)
treefdd02cf0b4f5d7a888a11f69f06950d5c904c236 /Objects
parent36eb4dfb819dbfe90d82e0c6b58bd360c22bcc26 (diff)
downloadcpython-bf9b24464e11d9db2980c018f4d67b50b3573903.zip
cpython-bf9b24464e11d9db2980c018f4d67b50b3573903.tar.gz
cpython-bf9b24464e11d9db2980c018f4d67b50b3573903.tar.bz2
slot_sq_contains(): This leaked a reference to the result of calling
__contains__(). Bugfix candidate.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index c2ed180..8dfb939 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4016,10 +4016,11 @@ static int
slot_sq_contains(PyObject *self, PyObject *value)
{
PyObject *func, *res, *args;
+ int result = -1;
+
static PyObject *contains_str;
func = lookup_maybe(self, "__contains__", &contains_str);
-
if (func != NULL) {
args = Py_BuildValue("(O)", value);
if (args == NULL)
@@ -4029,16 +4030,16 @@ slot_sq_contains(PyObject *self, PyObject *value)
Py_DECREF(args);
}
Py_DECREF(func);
- if (res == NULL)
- return -1;
- return PyObject_IsTrue(res);
+ if (res != NULL) {
+ result = PyObject_IsTrue(res);
+ Py_DECREF(res);
+ }
}
- else if (PyErr_Occurred())
- return -1;
- else {
- return _PySequence_IterSearch(self, value,
- PY_ITERSEARCH_CONTAINS);
+ else if (! PyErr_Occurred()) {
+ result = _PySequence_IterSearch(self, value,
+ PY_ITERSEARCH_CONTAINS);
}
+ return result;
}
SLOT1(slot_sq_inplace_concat, "__iadd__", PyObject *, "O")
@@ -4685,7 +4686,7 @@ slot_tp_del(PyObject *self)
/* Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper
- functions. The offsets here are relative to the 'PyHeapTypeObject'
+ functions. The offsets here are relative to the 'PyHeapTypeObject'
structure, which incorporates the additional structures used for numbers,
sequences and mappings.
Note that multiple names may map to the same slot (e.g. __eq__,
@@ -5216,7 +5217,7 @@ update_all_slots(PyTypeObject* type)
mp_subscript generate a __getitem__ descriptor).
In the latter case, the first slotdef entry encoutered wins. Since
- slotdef entries are sorted by the offset of the slot in the
+ slotdef entries are sorted by the offset of the slot in the
PyHeapTypeObject, this gives us some control over disambiguating
between competing slots: the members of PyHeapTypeObject are listed from most
general to least general, so the most general slot is preferred. In