mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Plug a leak and beef-up test coverage.
This commit is contained in:
parent
630e5355b5
commit
855d9a985b
2 changed files with 161 additions and 4 deletions
|
@ -28,8 +28,10 @@ _siftdown(PyListObject *heap, int startpos, int pos)
|
|||
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 @@ _siftup(PyListObject *heap, int pos)
|
|||
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 @@ _siftdownmax(PyListObject *heap, int startpos, int pos)
|
|||
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 @@ _siftupmax(PyListObject *heap, int pos)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue