Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b7d24e

Browse filesBrowse files
committed
Fix casting
1 parent d1ac2d4 commit 3b7d24e
Copy full SHA for 3b7d24e

File tree

Expand file treeCollapse file tree

1 file changed

+4
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-4
lines changed

‎Objects/listobject.c

Copy file name to clipboardExpand all lines: Objects/listobject.c
+4-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.