]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149816: fix thread safety of deletion of list slice (#149936)
authorKumar Aditya <kumaraditya@python.org>
Mon, 18 May 2026 16:38:37 +0000 (22:08 +0530)
committerGitHub <noreply@github.com>
Mon, 18 May 2026 16:38:37 +0000 (22:08 +0530)
Objects/listobject.c

index 10e25bbdcdcb6c538eca09f8f10e18db67577b2c..c76721c5d2ac9ea9e3379db4d3aa39d7636d1250 100644 (file)
@@ -3793,16 +3793,13 @@ list_ass_subscript_lock_held(PyObject *_self, PyObject *item, PyObject *value)
                     lim = Py_SIZE(self) - cur - 1;
                 }
 
-                memmove(self->ob_item + cur - i,
-                    self->ob_item + cur + 1,
-                    lim * sizeof(PyObject *));
+                ptr_wise_atomic_memmove(self, self->ob_item + cur - i,
+                    self->ob_item + cur + 1, lim);
             }
             cur = start + (size_t)slicelength * step;
             if (cur < (size_t)Py_SIZE(self)) {
-                memmove(self->ob_item + cur - slicelength,
-                    self->ob_item + cur,
-                    (Py_SIZE(self) - cur) *
-                     sizeof(PyObject *));
+                ptr_wise_atomic_memmove(self, self->ob_item + cur - slicelength,
+                    self->ob_item + cur, Py_SIZE(self) - cur);
             }
 
             Py_SET_SIZE(self, Py_SIZE(self) - slicelength);