mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
[3.13] gh-120298: Fix use-after-free in list_richcompare_impl
(GH-120303) (#120340)
gh-120298: Fix use-after-free in `list_richcompare_impl` (GH-120303)
(cherry picked from commit 141babad9b
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
81eae21733
commit
52225c64f7
3 changed files with 21 additions and 1 deletions
|
@ -3382,7 +3382,14 @@ list_richcompare_impl(PyObject *v, PyObject *w, int op)
|
|||
}
|
||||
|
||||
/* Compare the final item again using the proper operator */
|
||||
return PyObject_RichCompare(vl->ob_item[i], wl->ob_item[i], op);
|
||||
PyObject *vitem = vl->ob_item[i];
|
||||
PyObject *witem = wl->ob_item[i];
|
||||
Py_INCREF(vitem);
|
||||
Py_INCREF(witem);
|
||||
PyObject *result = PyObject_RichCompare(vl->ob_item[i], wl->ob_item[i], op);
|
||||
Py_DECREF(vitem);
|
||||
Py_DECREF(witem);
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue