summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-07-16 04:29:16 (GMT)
committerGitHub <noreply@github.com>2017-07-16 04:29:16 (GMT)
commit49f6449ef4b81537c19b82329caaf60596c516c2 (patch)
tree416e402ff426c12cca2324506363d4be167adf95 /Modules
parent95bebb7264afad88f31f7cdc3b28bacde7c46f93 (diff)
downloadcpython-49f6449ef4b81537c19b82329caaf60596c516c2.zip
cpython-49f6449ef4b81537c19b82329caaf60596c516c2.tar.gz
cpython-49f6449ef4b81537c19b82329caaf60596c516c2.tar.bz2
bpo-30936: Fix a reference leak in json when fail to sort keys. (#2712)
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)