mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Fix a refleak in bytearray.split and bytearray.rsplit, detected by
regrtest.py -R:: test_bytes
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user