summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index a84b085..1be4c17 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1601,8 +1601,10 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
if (items == NULL)
goto bail;
sortkeys = PyObject_IsTrue(s->sort_keys);
- if (sortkeys < 0 || (sortkeys && PyList_Sort(items) < 0))
+ if (sortkeys < 0 || (sortkeys && PyList_Sort(items) < 0)) {
+ Py_DECREF(items);
goto bail;
+ }
it = PyObject_GetIter(items);
Py_DECREF(items);
if (it == NULL)