summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_json.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 07bcd31..6cc31c6 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -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)