Fix a refleak in bytearray.split and bytearray.rsplit, detected by

regrtest.py -R:: test_bytes
This commit is contained in:
Amaury Forgeot d'Arc 2008-08-17 21:05:18 +00:00
parent 37553fdb95
commit 313bda12e8
1 changed files with 10 additions and 4 deletions

View File

@ -2295,8 +2295,11 @@ bytes_split(PyByteArrayObject *self, PyObject *args)
PyBuffer_Release(&vsub);
return NULL;
}
if (n == 1)
return split_char(s, len, sub[0], maxsplit);
if (n == 1) {
list = split_char(s, len, sub[0], maxsplit);
PyBuffer_Release(&vsub);
return list;
}
list = PyList_New(PREALLOC_SIZE(maxsplit));
if (list == NULL) {
@ -2527,8 +2530,11 @@ bytes_rsplit(PyByteArrayObject *self, PyObject *args)
PyBuffer_Release(&vsub);
return NULL;
}
else if (n == 1)
return rsplit_char(s, len, sub[0], maxsplit);
else if (n == 1) {
list = rsplit_char(s, len, sub[0], maxsplit);
PyBuffer_Release(&vsub);
return list;
}
list = PyList_New(PREALLOC_SIZE(maxsplit));
if (list == NULL) {