summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-04-01 14:08:11 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-04-01 14:08:11 (GMT)
commit29b964d0ddebad90c252139911f6702632b55b8a (patch)
treef19de550844eac79362d3c46d158ed578b4aa426 /Objects
parent2d95c4e835829c993feb1e3b35c572d9a9a6eb02 (diff)
parent58bb82e7b4b50fa5efaefc1196bd927992fbe783 (diff)
downloadcpython-29b964d0ddebad90c252139911f6702632b55b8a.zip
cpython-29b964d0ddebad90c252139911f6702632b55b8a.tar.gz
cpython-29b964d0ddebad90c252139911f6702632b55b8a.tar.bz2
Issue #13019: Fix potential reference leaks in bytearray.extend().
Patch by Suman Saha.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 1b88f12..1846ec5 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2289,8 +2289,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
}
bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
- if (bytearray_obj == NULL)
+ if (bytearray_obj == NULL) {
+ Py_DECREF(it);
return NULL;
+ }
buf = PyByteArray_AS_STRING(bytearray_obj);
while ((item = PyIter_Next(it)) != NULL) {
@@ -2323,8 +2325,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
return NULL;
}
- if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1)
+ if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) {
+ Py_DECREF(bytearray_obj);
return NULL;
+ }
Py_DECREF(bytearray_obj);
Py_RETURN_NONE;