]> granicus.if.org Git - python/commitdiff
fix more possible ref leaks in _json and use Py_CLEAR
authorBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 21:48:06 +0000 (21:48 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 21:48:06 +0000 (21:48 +0000)
Modules/_json.c

index 437eab0eae3322712e3ee14e8b851a719f264031..2e77f1c995ccc647c99d285761110087d7e126ed 100644 (file)
@@ -271,6 +271,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
                 goto bail;
             }
             if (PyList_Append(chunks, chunk)) {
+                Py_DECREF(chunk);
                 goto bail;
             }
             Py_DECREF(chunk);
@@ -372,6 +373,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
             goto bail;
         }
         if (PyList_Append(chunks, chunk)) {
+            Py_DECREF(chunk);
             goto bail;
         }
         Py_DECREF(chunk);
@@ -381,8 +383,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
     if (rval == NULL) {
         goto bail;
     }
-    Py_DECREF(chunks);
-    chunks = NULL;
+    Py_CLEAR(chunks);
     return Py_BuildValue("(Nn)", rval, end);
 bail:
     Py_XDECREF(chunks);
@@ -533,6 +534,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
             goto bail;
         }
         if (PyList_Append(chunks, chunk)) {
+            Py_DECREF(chunk);
             goto bail;
         }
         Py_DECREF(chunk);