summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-01-03 09:20:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-01-03 09:20:15 (GMT)
commit0f0551210452506d7d5bb40a427ab82986f87a45 (patch)
tree0bc8ac6f78b492f50f82d760c30dcc61c32be830 /Modules
parentef29a05f9851ca37a4b63cb2889bc6ec0f0f9bb0 (diff)
parent8d979d576e123c03f0bb92aeb8043b8d7aa57cf7 (diff)
downloadcpython-0f0551210452506d7d5bb40a427ab82986f87a45.zip
cpython-0f0551210452506d7d5bb40a427ab82986f87a45.tar.gz
cpython-0f0551210452506d7d5bb40a427ab82986f87a45.tar.bz2
Fixed possible reference leaks in the _json module.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_json.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 5cf39f2..d3fb784 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -845,14 +845,16 @@ _parse_array_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssi
int kind;
Py_ssize_t end_idx;
PyObject *val = NULL;
- PyObject *rval = PyList_New(0);
+ PyObject *rval;
Py_ssize_t next_idx;
- if (rval == NULL)
- return NULL;
if (PyUnicode_READY(pystr) == -1)
return NULL;
+ rval = PyList_New(0);
+ if (rval == NULL)
+ return NULL;
+
str = PyUnicode_DATA(pystr);
kind = PyUnicode_KIND(pystr);
end_idx = PyUnicode_GET_LENGTH(pystr) - 1;
@@ -1559,8 +1561,11 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc,
return -1;
}
- if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+ if (Py_EnterRecursiveCall(" while encoding a JSON object")) {
+ Py_DECREF(newobj);
+ Py_XDECREF(ident);
return -1;
+ }
rv = encoder_listencode_obj(s, acc, newobj, indent_level);
Py_LeaveRecursiveCall();