diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-01 14:05:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-01 14:05:46 (GMT) |
commit | fe9417726c8d2a15ae11f553ae521c3ba6dfc6b7 (patch) | |
tree | 04e618c07a90c5ac56dfb49dd1430ebc192e1ed8 /Objects | |
parent | d987c0221cf6601ab65ddf00ca62475d56e6cbd4 (diff) | |
download | cpython-fe9417726c8d2a15ae11f553ae521c3ba6dfc6b7.zip cpython-fe9417726c8d2a15ae11f553ae521c3ba6dfc6b7.tar.gz cpython-fe9417726c8d2a15ae11f553ae521c3ba6dfc6b7.tar.bz2 |
Issue #13019: Fix potential reference leaks in bytearray.extend().
Patch by Suman Saha.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytearrayobject.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index a40c0ab..0360463 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2296,8 +2296,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) { @@ -2330,8 +2332,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; |