diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-07-16 04:48:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-16 04:48:08 (GMT) |
commit | a819e5e1e66a1a5f9a7073c8a1ff3c3f304c917b (patch) | |
tree | c732b96b2ec5166746d65d0f14c6465c867a5f6e /Modules/_json.c | |
parent | 28343e3392ca7b1ec7151f68d4d92c90efb91e50 (diff) | |
download | cpython-a819e5e1e66a1a5f9a7073c8a1ff3c3f304c917b.zip cpython-a819e5e1e66a1a5f9a7073c8a1ff3c3f304c917b.tar.gz cpython-a819e5e1e66a1a5f9a7073c8a1ff3c3f304c917b.tar.bz2 |
[3.6] bpo-30936: Fix a reference leak in json when fail to sort keys. (GH-2712). (#2727)
(cherry picked from commit 49f6449ef4b81537c19b82329caaf60596c516c2)
Diffstat (limited to 'Modules/_json.c')
-rw-r--r-- | Modules/_json.c | 4 |
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) |