]> granicus.if.org Git - python/commitdiff
PyUnicode_AsUTF8String(): Don't need to explicitly incref str since
authorBarry Warsaw <barry@python.org>
Fri, 18 Aug 2000 06:58:15 +0000 (06:58 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 18 Aug 2000 06:58:15 +0000 (06:58 +0000)
PyUnicode_EncodeUTF8() already returns the created object with the
proper reference count.  This fixes an Insure reported memory leak.

Objects/unicodeobject.c

index f4dc9bfe7e60ea822edd5a1f8a2fb7c97f192ab0..1d35c3d3805ff02d5a1366b10c5303f6cd891cfe 100644 (file)
@@ -907,13 +907,9 @@ PyObject *PyUnicode_AsUTF8String(PyObject *unicode)
         PyErr_BadArgument();
         return NULL;
     }
-    str = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
-                              PyUnicode_GET_SIZE(unicode),
-                              NULL);
-    if (str == NULL)
-        return NULL;
-    Py_INCREF(str);
-    return str;
+    return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
+                               PyUnicode_GET_SIZE(unicode),
+                               NULL);
 }
 
 /* --- UTF-16 Codec ------------------------------------------------------- */