diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-08-17 21:05:18 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-08-17 21:05:18 (GMT) |
commit | 313bda12e8dfe618c6ef2f3681b5ce02409891c8 (patch) | |
tree | e9ffd14d27aef986bcac59f8b153ae8375fe5f1b /Objects/bytearrayobject.c | |
parent | 37553fdb951e55186428d011a3c79c5ba6289df7 (diff) | |
download | cpython-313bda12e8dfe618c6ef2f3681b5ce02409891c8.zip cpython-313bda12e8dfe618c6ef2f3681b5ce02409891c8.tar.gz cpython-313bda12e8dfe618c6ef2f3681b5ce02409891c8.tar.bz2 |
Fix a refleak in bytearray.split and bytearray.rsplit, detected by
regrtest.py -R:: test_bytes
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 9ff4458..5ba1f6d 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -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) { |