[Python-checkins] cpython: Plug some (unlikely) refleaks.

antoine.pitrou python-checkins at python.org
Sat Nov 12 18:14:28 CET 2011


http://hg.python.org/cpython/rev/9688c634f0d9
changeset:   73519:9688c634f0d9
parent:      73517:64485e0700ba
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Nov 12 18:05:15 2011 +0100
summary:
  Plug some (unlikely) refleaks.

files:
  Modules/_codecsmodule.c |  60 +++++++++++++++++++++-------
  1 files changed, 45 insertions(+), 15 deletions(-)


diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -720,8 +720,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF7(str, 0, 0, errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -740,8 +742,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) == -1)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(PyUnicode_AsEncodedString(str, "utf-8", errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -768,8 +772,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, byteorder),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -788,8 +794,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, -1),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -808,8 +816,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, +1),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -836,8 +846,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, byteorder),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -856,8 +868,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, -1),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -876,8 +890,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, +1),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -896,8 +912,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(PyUnicode_AsUnicodeEscapeString(str),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -916,8 +934,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(PyUnicode_AsRawUnicodeEscapeString(str),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -936,8 +956,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_AsLatin1String(str, errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -956,8 +978,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_AsASCIIString(str, errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -979,8 +1003,10 @@
         mapping = NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(_PyUnicode_EncodeCharmap(str, mapping, errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -1010,8 +1036,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(PyUnicode_EncodeCodePage(CP_ACP, str, errors),
                     PyUnicode_GET_LENGTH(str));
     Py_DECREF(str);
@@ -1031,8 +1059,10 @@
         return NULL;
 
     str = PyUnicode_FromObject(str);
-    if (str == NULL || PyUnicode_READY(str) < 0)
+    if (str == NULL || PyUnicode_READY(str) < 0) {
+        Py_XDECREF(str);
         return NULL;
+    }
     v = codec_tuple(PyUnicode_EncodeCodePage(code_page,
                                              str,
                                              errors),

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list