]> granicus.if.org Git - python/commitdiff
Add an early-out for deque_clear()
authorRaymond Hettinger <python@rcn.com>
Wed, 30 Sep 2015 05:45:05 +0000 (22:45 -0700)
committerRaymond Hettinger <python@rcn.com>
Wed, 30 Sep 2015 05:45:05 +0000 (22:45 -0700)
Modules/_collectionsmodule.c

index 5db7aed37735edcedd5eccfd95beb5532e888bdb..d9df5749e19c89ae0c2690bfef4e0be58c1a28a6 100644 (file)
@@ -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