[Python-checkins] python/dist/src/Modules _heapqmodule.c,1.7,1.8
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Sep 28 02:04:26 CEST 2004
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16444/Modules
Modified Files:
_heapqmodule.c
Log Message:
Plug a leak and beef-up test coverage.
Index: _heapqmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_heapqmodule.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- _heapqmodule.c 6 Sep 2004 07:04:08 -0000 1.7
+++ _heapqmodule.c 28 Sep 2004 00:03:53 -0000 1.8
@@ -28,8 +28,10 @@
parentpos = (pos - 1) >> 1;
parent = PyList_GET_ITEM(heap, parentpos);
cmp = PyObject_RichCompareBool(parent, newitem, Py_LE);
- if (cmp == -1)
+ if (cmp == -1) {
+ Py_DECREF(newitem);
return -1;
+ }
if (cmp == 1)
break;
Py_INCREF(parent);
@@ -69,8 +71,10 @@
PyList_GET_ITEM(heap, rightpos),
PyList_GET_ITEM(heap, childpos),
Py_LE);
- if (cmp == -1)
+ if (cmp == -1) {
+ Py_DECREF(newitem);
return -1;
+ }
if (cmp == 1)
childpos = rightpos;
}
@@ -315,8 +319,10 @@
parentpos = (pos - 1) >> 1;
parent = PyList_GET_ITEM(heap, parentpos);
cmp = PyObject_RichCompareBool(newitem, parent, Py_LE);
- if (cmp == -1)
+ if (cmp == -1) {
+ Py_DECREF(newitem);
return -1;
+ }
if (cmp == 1)
break;
Py_INCREF(parent);
@@ -356,8 +362,10 @@
PyList_GET_ITEM(heap, childpos),
PyList_GET_ITEM(heap, rightpos),
Py_LE);
- if (cmp == -1)
+ if (cmp == -1) {
+ Py_DECREF(newitem);
return -1;
+ }
if (cmp == 1)
childpos = rightpos;
}
More information about the Python-checkins
mailing list