summaryrefslogtreecommitdiff
path: root/tests/basics/deque1.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-21 23:34:17 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-21 23:34:17 +1100
commit160d6708684de8c71895f90bc699a5879fb6ed29 (patch)
treead45452d4a64c7e6fe1e50ccdb8af5125b96828c /tests/basics/deque1.py
parent8f9b113be25bec821254027e3e3d634f20553226 (diff)
py/objdeque: Protect against negative maxlen in deque constructor.
Otherwise passing -1 as maxlen will lead to a zero allocation and subsequent unbound buffer overflow in deque.append() because i_put is allowed to grow without bound.
Diffstat (limited to 'tests/basics/deque1.py')
-rw-r--r--tests/basics/deque1.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basics/deque1.py b/tests/basics/deque1.py
index 6b5669c45..19966fcb0 100644
--- a/tests/basics/deque1.py
+++ b/tests/basics/deque1.py
@@ -55,6 +55,12 @@ d.append(4)
d.append(5)
print(d.popleft(), d.popleft())
+# Negative maxlen is not allowed
+try:
+ deque((), -1)
+except ValueError:
+ print("ValueError")
+
# Unsupported unary op
try:
~d