summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-04-01 14:05:46 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-04-01 14:05:46 (GMT)
commit58bb82e7b4b50fa5efaefc1196bd927992fbe783 (patch)
tree297fc8ec19a5e746c40b6b140dba83f90b9e3c0c /Objects
parent165a2c2e27c07ac0c1ab5092a79f7f30c6c2a0d6 (diff)
downloadcpython-58bb82e7b4b50fa5efaefc1196bd927992fbe783.zip
cpython-58bb82e7b4b50fa5efaefc1196bd927992fbe783.tar.gz
cpython-58bb82e7b4b50fa5efaefc1196bd927992fbe783.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 4202ff2..55b4df6 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2234,8 +2234,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) {
@@ -2268,8 +2270,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;