]> granicus.if.org Git - python/commitdiff
Merged revisions 66938,66942 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 21:56:24 +0000 (21:56 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 16 Oct 2008 21:56:24 +0000 (21:56 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66938 | benjamin.peterson | 2008-10-16 16:27:54 -0500 (Thu, 16 Oct 2008) | 1 line

  fix possible ref leak
........
  r66942 | benjamin.peterson | 2008-10-16 16:48:06 -0500 (Thu, 16 Oct 2008) | 1 line

  fix more possible ref leaks in _json and use Py_CLEAR
........

Modules/_json.c

index 0068bda9d2dfb73af65b91c0fd585ef0b12d3e28..9c35f64484f051815ea8d97f3816e58b11519d56 100644 (file)
@@ -276,6 +276,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);
@@ -377,6 +378,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);
@@ -386,8 +388,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);
@@ -436,6 +437,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);
@@ -537,6 +539,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);
@@ -546,8 +549,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, 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);