summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2004-08-02 13:24:54 (GMT)
committerMichael W. Hudson <mwh@python.net>2004-08-02 13:24:54 (GMT)
commitc9f510aed2e41666372579b578fb3c590e346386 (patch)
treebd7c1dcdcbc3ad9a52d18379a3f31704c1ded2da /Modules
parentf8df9a89bcb8304862ed22328b40240535ddeafc (diff)
downloadcpython-c9f510aed2e41666372579b578fb3c590e346386.zip
cpython-c9f510aed2e41666372579b578fb3c590e346386.tar.gz
cpython-c9f510aed2e41666372579b578fb3c590e346386.tar.bz2
Any call to insort_{left,right} with a non-list leaked a reference to None
(or to whatever the 'insert' method chose to return).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bisectmodule.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
index d336158..f4016fe 100644
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -65,7 +65,7 @@ slice of a to be searched.\n");
static PyObject *
insort_right(PyObject *self, PyObject *args)
{
- PyObject *list, *item;
+ PyObject *list, *item, *result;
int lo = 0;
int hi = -1;
int index;
@@ -80,9 +80,11 @@ insort_right(PyObject *self, PyObject *args)
if (PyList_Insert(list, index, item) < 0)
return NULL;
} else {
- if (PyObject_CallMethod(list, "insert", "iO", index, item)
- == NULL)
+ result = PyObject_CallMethod(list, "insert", "iO",
+ index, item);
+ if (result == NULL)
return NULL;
+ Py_DECREF(result);
}
Py_RETURN_NONE;
@@ -158,7 +160,7 @@ slice of a to be searched.\n");
static PyObject *
insort_left(PyObject *self, PyObject *args)
{
- PyObject *list, *item;
+ PyObject *list, *item, *result;
int lo = 0;
int hi = -1;
int index;
@@ -173,9 +175,11 @@ insort_left(PyObject *self, PyObject *args)
if (PyList_Insert(list, index, item) < 0)
return NULL;
} else {
- if (PyObject_CallMethod(list, "insert", "iO", index, item)
- == NULL)
+ result = PyObject_CallMethod(list, "insert", "iO",
+ index, item);
+ if (result == NULL)
return NULL;
+ Py_DECREF(result);
}
Py_RETURN_NONE;