Skip to content

Commit 3b7d24e

Browse files
committed
Fix casting
1 parent d1ac2d4 commit 3b7d24e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Objects/listobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ free_list_items(PyObject** items, bool use_qsbr)
9090
static int
9191
list_resize(PyListObject *self, Py_ssize_t newsize)
9292
{
93-
Py_ssize_t new_allocated;
93+
size_t new_allocated;
9494
Py_ssize_t allocated = self->allocated;
9595

9696
/* Bypass realloc() when a previous overallocation is large enough
@@ -138,11 +138,11 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
138138
}
139139
PyObject **old_items = self->ob_item;
140140
if (self->ob_item) {
141-
if (allocated < new_allocated) {
142-
memcpy(&array->ob_item, self->ob_item, allocated * sizeof(PyObject*));
141+
if (new_allocated < (size_t)allocated) {
142+
memcpy(&array->ob_item, self->ob_item, new_allocated * sizeof(PyObject*));
143143
}
144144
else {
145-
memcpy(&array->ob_item, self->ob_item, new_allocated * sizeof(PyObject*));
145+
memcpy(&array->ob_item, self->ob_item, allocated * sizeof(PyObject*));
146146
}
147147
}
148148
_Py_atomic_store_ptr_release(&self->ob_item, &array->ob_item);

0 commit comments

Comments
 (0)