mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-38588: Fix possible crashes in dict and list when calling PyObject_RichCompareBool (GH-17734)
Take strong references before calling PyObject_RichCompareBool to protect against the case where the object dies during the call.
This commit is contained in:
parent
ee9ff05ec2
commit
2d5bf568ea
5 changed files with 47 additions and 1 deletions
|
@ -2777,9 +2777,11 @@ dict_equal(PyDictObject *a, PyDictObject *b)
|
|||
return -1;
|
||||
return 0;
|
||||
}
|
||||
Py_INCREF(bval);
|
||||
cmp = PyObject_RichCompareBool(aval, bval, Py_EQ);
|
||||
Py_DECREF(key);
|
||||
Py_DECREF(aval);
|
||||
Py_DECREF(bval);
|
||||
if (cmp <= 0) /* error or not equal */
|
||||
return cmp;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue