From 38031143fbab6267fe464a1cb39eeb5c68de38f4 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 29 Sep 2015 22:45:05 -0700 Subject: [PATCH] Add an early-out for deque_clear() --- Modules/_collectionsmodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 5db7aed3773..d9df5749e19 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