]> granicus.if.org Git - python/commitdiff
#3650: fix a reference leak in bytes.split('x')
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Fri, 22 Aug 2008 22:05:20 +0000 (22:05 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Fri, 22 Aug 2008 22:05:20 +0000 (22:05 +0000)
Actually the same as r65785, but trunk only has bytearray.

Misc/NEWS
Objects/bytesobject.c

index 89ffdc1a07da2830b2a927e1cc00a959cd88a117..3173fcb71c3e69a11e52068e422e00abd778b9f5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.0 release candidate 1
 Core and Builtins
 -----------------
 
+- Issue #3650: Fixed a reference leak in bytes.split('x').
+
 Library
 -------
 
index 52479ca41d749196c12ca93fa54c8518c0565e44..bfb4ff8fd3c7f62973cc9ddb1a18c26234e518a4 100644 (file)
@@ -1163,8 +1163,11 @@ string_split(PyBytesObject *self, PyObject *args)
                PyBuffer_Release(&vsub);
                return NULL;
        }
-       else if (n == 1)
-               return split_char(self, len, sub[0], maxsplit);
+       else if (n == 1) {
+               list = split_char(self, len, sub[0], maxsplit);
+               PyBuffer_Release(&vsub);
+               return list;
+       }
 
        list = PyList_New(PREALLOC_SIZE(maxsplit));
        if (list == NULL) {
@@ -1379,8 +1382,11 @@ string_rsplit(PyBytesObject *self, PyObject *args)
                PyBuffer_Release(&vsub);
                return NULL;
        }
-       else if (n == 1)
-               return rsplit_char(self, len, sub[0], maxsplit);
+       else if (n == 1) {
+               list = rsplit_char(self, len, sub[0], maxsplit);
+               PyBuffer_Release(&vsub);
+               return list;
+       }
 
        list = PyList_New(PREALLOC_SIZE(maxsplit));
        if (list == NULL) {