mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +00:00
make sure to not call memcpy with a NULL second argument
This commit is contained in:
parent
8c94f97465
commit
5a7d923e75
1 changed files with 9 additions and 6 deletions
|
|
@ -634,14 +634,17 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
||||||
item = a->ob_item;
|
item = a->ob_item;
|
||||||
/* recycle the items that we are about to remove */
|
/* recycle the items that we are about to remove */
|
||||||
s = norig * sizeof(PyObject *);
|
s = norig * sizeof(PyObject *);
|
||||||
if (s > sizeof(recycle_on_stack)) {
|
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
|
||||||
recycle = (PyObject **)PyMem_MALLOC(s);
|
if (s) {
|
||||||
if (recycle == NULL) {
|
if (s > sizeof(recycle_on_stack)) {
|
||||||
PyErr_NoMemory();
|
recycle = (PyObject **)PyMem_MALLOC(s);
|
||||||
goto Error;
|
if (recycle == NULL) {
|
||||||
|
PyErr_NoMemory();
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
memcpy(recycle, &item[ilow], s);
|
||||||
}
|
}
|
||||||
memcpy(recycle, &item[ilow], s);
|
|
||||||
|
|
||||||
if (d < 0) { /* Delete -d items */
|
if (d < 0) { /* Delete -d items */
|
||||||
Py_ssize_t tail;
|
Py_ssize_t tail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue