[Python-checkins] cpython (merge 3.5 -> 3.6): Fixed possible reference leaks in the _json module.
serhiy.storchaka
python-checkins at python.org
Tue Jan 3 04:20:39 EST 2017
https://hg.python.org/cpython/rev/8f4e2080e7a5
changeset: 105989:8f4e2080e7a5
branch: 3.6
parent: 105985:f64ede8c65d9
parent: 105987:523589096d04
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Jan 03 11:19:48 2017 +0200
summary:
Fixed possible reference leaks in the _json module.
files:
Modules/_json.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Modules/_json.c b/Modules/_json.c
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -845,12 +845,14 @@
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)
+
+ if (PyUnicode_READY(pystr) == -1)
return NULL;
- if (PyUnicode_READY(pystr) == -1)
+ rval = PyList_New(0);
+ if (rval == NULL)
return NULL;
str = PyUnicode_DATA(pystr);
@@ -1559,8 +1561,11 @@
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();
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list