Skip to content

Commit 7712b1d

Browse files
committed
chore: add total_size
1 parent 31f4513 commit 7712b1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Modules/arraymodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,15 +1600,16 @@ array_array_tofile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f)
16001600

16011601
Py_ssize_t offset = 0;
16021602
while (1) {
1603-
if (self->ob_item == NULL || Py_SIZE(self) == 0) {
1603+
Py_ssize_t total_size = Py_SIZE(self);
1604+
if (self->ob_item == NULL || total_size == 0) {
16041605
break;
16051606
}
16061607

1607-
if (Py_SIZE(self) > max_items) {
1608+
if (total_size > max_items) {
16081609
return PyErr_NoMemory();
16091610
}
16101611

1611-
Py_ssize_t current_nbytes = Py_SIZE(self) * self->ob_descr->itemsize;
1612+
Py_ssize_t current_nbytes = total_size * self->ob_descr->itemsize;
16121613
if (offset >= current_nbytes) {
16131614
break;
16141615
}

0 commit comments

Comments
 (0)