summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-09-29 22:45:05 -0700
committerRaymond Hettinger <python@rcn.com>2015-09-29 22:45:05 -0700
commitdb9ecf74f98c73eebe111c51a8a93ca6e70e02d3 (patch)
tree66da4d2c086210e6a288fcd827b1a7015818142e /Modules
parent309b0bd8454aff1f30e14283a7078dafaf20d8f0 (diff)
downloadcpython-db9ecf74f98c73eebe111c51a8a93ca6e70e02d3.tar.gz
Add an early-out for deque_clear()
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_collectionsmodule.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 5db7aed377..d9df5749e1 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