summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 277be59..388e990 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -3192,8 +3192,12 @@ static PyObject *
bytearrayiter_length_hint(bytesiterobject *it)
{
Py_ssize_t len = 0;
- if (it->it_seq)
+ if (it->it_seq) {
len = PyByteArray_GET_SIZE(it->it_seq) - it->it_index;
+ if (len < 0) {
+ len = 0;
+ }
+ }
return PyLong_FromSsize_t(len);
}