mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
bpo-30936: Fix a reference leak in json when fail to sort keys. (#2712)
This commit is contained in:
parent
95bebb7264
commit
49f6449ef4
2 changed files with 7 additions and 1 deletions
|
|
@ -1589,8 +1589,10 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
|
|||
items = PyMapping_Items(dct);
|
||||
if (items == NULL)
|
||||
goto bail;
|
||||
if (s->sort_keys && PyList_Sort(items) < 0)
|
||||
if (s->sort_keys && PyList_Sort(items) < 0) {
|
||||
Py_DECREF(items);
|
||||
goto bail;
|
||||
}
|
||||
it = PyObject_GetIter(items);
|
||||
Py_DECREF(items);
|
||||
if (it == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue