summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-08-22 22:05:20 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-08-22 22:05:20 (GMT)
commit20443f30436cd93b491286a596063a9ede832467 (patch)
tree465fc9c9cff4dfdce3bfa25364b6f380f91d4d34 /Objects
parentb6f9806bd6d5495271e14029acc1e8f1e7de97bc (diff)
downloadcpython-20443f30436cd93b491286a596063a9ede832467.zip
cpython-20443f30436cd93b491286a596063a9ede832467.tar.gz
cpython-20443f30436cd93b491286a596063a9ede832467.tar.bz2
#3650: fix a reference leak in bytes.split('x')
Actually the same as r65785, but trunk only has bytearray.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 52479ca..bfb4ff8 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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) {