diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-04-04 14:52:36 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-04-04 14:52:36 (GMT) |
commit | 1a6292194bdef5f4ee6298b95201b51564d1f93a (patch) | |
tree | 2410b3f04ffc6a78db1ac78b8181672489af1f8b /Modules/_collectionsmodule.c | |
parent | de1c27feaa75feaa2b23dae92f0b35abb3d9b792 (diff) | |
download | cpython-1a6292194bdef5f4ee6298b95201b51564d1f93a.zip cpython-1a6292194bdef5f4ee6298b95201b51564d1f93a.tar.gz cpython-1a6292194bdef5f4ee6298b95201b51564d1f93a.tar.bz2 |
fix refleak in deque_concat
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r-- | Modules/_collectionsmodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 9f6c47f..2b70b2b 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -507,7 +507,7 @@ static PyObject *deque_copy(PyObject *deque); static PyObject * deque_concat(dequeobject *deque, PyObject *other) { - PyObject *new_deque; + PyObject *new_deque, *result; int rv; rv = PyObject_IsInstance(other, (PyObject *)&deque_type); @@ -523,7 +523,13 @@ deque_concat(dequeobject *deque, PyObject *other) new_deque = deque_copy((PyObject *)deque); if (new_deque == NULL) return NULL; - return deque_inplace_concat((dequeobject *)new_deque, other); + result = deque_extend((dequeobject *)new_deque, other); + if (result == NULL) { + Py_DECREF(new_deque); + return NULL; + } + Py_DECREF(result); + return new_deque; } static void deque_clear(dequeobject *deque); |