Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3803114

Browse files
committed
Add an early-out for deque_clear()
1 parent 17f9716 commit 3803114

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Modules/_collectionsmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ deque_clear(dequeobject *deque)
595595
Py_ssize_t n;
596596
PyObject *item;
597597

598+
if (Py_SIZE(deque) == 0)
599+
return;
600+
598601
/* During the process of clearing a deque, decrefs can cause the
599602
deque to mutate. To avoid fatal confusion, we have to make the
600603
deque empty before clearing the blocks and never refer to

0 commit comments

Comments
 (0)