[Python-checkins] cpython (merge 3.5 -> default): merge 3.5
benjamin.peterson
python-checkins at python.org
Tue Sep 6 20:59:11 EDT 2016
https://hg.python.org/cpython/rev/c2158e5456d8
changeset: 103190:c2158e5456d8
parent: 103187:9e97d985cee8
parent: 103188:5f3f6f1fb73a
user: Benjamin Peterson <benjamin at python.org>
date: Tue Sep 06 17:58:44 2016 -0700
summary:
merge 3.5
files:
Objects/listobject.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Objects/listobject.c b/Objects/listobject.c
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -634,14 +634,17 @@
item = a->ob_item;
/* recycle the items that we are about to remove */
s = norig * sizeof(PyObject *);
- if (s > sizeof(recycle_on_stack)) {
- recycle = (PyObject **)PyMem_MALLOC(s);
- if (recycle == NULL) {
- PyErr_NoMemory();
- goto Error;
+ /* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
+ if (s) {
+ if (s > sizeof(recycle_on_stack)) {
+ recycle = (PyObject **)PyMem_MALLOC(s);
+ if (recycle == NULL) {
+ PyErr_NoMemory();
+ goto Error;
+ }
}
+ memcpy(recycle, &item[ilow], s);
}
- memcpy(recycle, &item[ilow], s);
if (d < 0) { /* Delete -d items */
Py_ssize_t tail;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list