]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixed possible reference leaks in the _json module.
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 3 Jan 2017 09:17:44 +0000 (11:17 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 3 Jan 2017 09:17:44 +0000 (11:17 +0200)
Modules/_json.c

index f82af347cbb3e98adcb3ca1384b9c56c37cda7a1..47c9b0d2f7758b82a989c404ce1f00c02512f019 100644 (file)
@@ -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();