#3650: fix a reference leak in bytes.split('x')
Actually the same as r65785, but trunk only has bytearray.
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 @@
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 @@
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) {