Fix a refleak in bytearray.split and bytearray.rsplit, detected by
regrtest.py -R:: test_bytes
This commit is contained in:
parent
37553fdb95
commit
313bda12e8
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue