summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-09-30 05:45:05 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-09-30 05:45:05 (GMT)
commit38031143fbab6267fe464a1cb39eeb5c68de38f4 (patch)
treed4d47291ee5924d9cde2e10c1fafcdf8961fea6e /Modules/_collectionsmodule.c
parent17f97166766fd2ebe46df0f9fe9308182d141529 (diff)
downloadcpython-38031143fbab6267fe464a1cb39eeb5c68de38f4.zip
cpython-38031143fbab6267fe464a1cb39eeb5c68de38f4.tar.gz
cpython-38031143fbab6267fe464a1cb39eeb5c68de38f4.tar.bz2
Add an early-out for deque_clear()
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 5db7aed..d9df574 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -595,6 +595,9 @@ deque_clear(dequeobject *deque)
Py_ssize_t n;
PyObject *item;
+ if (Py_SIZE(deque) == 0)
+ return;
+
/* During the process of clearing a deque, decrefs can cause the
deque to mutate. To avoid fatal confusion, we have to make the
deque empty before clearing the blocks and never refer to