diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-02-14 13:09:30 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-02-14 13:09:30 (GMT) |
commit | 5a41a4c235ed09e08d7325e64c9ee2b485f54670 (patch) | |
tree | 038e63c469b9d6b07e42447b11c9b3f031f14917 /Objects/listobject.c | |
parent | db01a3e71ca993a8bf0c420f179e65a622c86ff0 (diff) | |
download | cpython-5a41a4c235ed09e08d7325e64c9ee2b485f54670.zip cpython-5a41a4c235ed09e08d7325e64c9ee2b485f54670.tar.gz cpython-5a41a4c235ed09e08d7325e64c9ee2b485f54670.tar.bz2 |
Merged revisions 78185 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r78185 | mark.dickinson | 2010-02-14 12:53:32 +0000 (Sun, 14 Feb 2010) | 13 lines
Merged revisions 78183-78184 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78183 | mark.dickinson | 2010-02-14 12:16:43 +0000 (Sun, 14 Feb 2010) | 1 line
Silence some 'comparison between signed and unsigned' compiler warnings.
........
r78184 | mark.dickinson | 2010-02-14 12:31:26 +0000 (Sun, 14 Feb 2010) | 1 line
Silence more compiler warnings; fix an instance of potential undefined behaviour from signed overflow.
........
................
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index c1ece2b..38468f3 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -126,11 +126,11 @@ PyList_New(Py_ssize_t size) PyErr_BadInternalCall(); return NULL; } - nbytes = size * sizeof(PyObject *); /* Check for overflow without an actual overflow, * which can cause compiler to optimise out */ - if (size > PY_SIZE_MAX / sizeof(PyObject *)) + if ((size_t)size > PY_SIZE_MAX / sizeof(PyObject *)) return PyErr_NoMemory(); + nbytes = size * sizeof(PyObject *); if (numfree) { numfree--; op = free_list[numfree]; @@ -1343,7 +1343,7 @@ merge_getmem(MergeState *ms, Py_ssize_t need) * we don't care what's in the block. */ merge_freemem(ms); - if (need > PY_SSIZE_T_MAX / sizeof(PyObject*)) { + if ((size_t)need > PY_SSIZE_T_MAX / sizeof(PyObject*)) { PyErr_NoMemory(); return -1; } @@ -2442,7 +2442,8 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) step = -step; } - assert(slicelength <= PY_SIZE_MAX / sizeof(PyObject*)); + assert((size_t)slicelength <= + PY_SIZE_MAX / sizeof(PyObject*)); garbage = (PyObject**) PyMem_MALLOC(slicelength*sizeof(PyObject*)); @@ -2458,13 +2459,13 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) and then tail end of the list that was not covered by the slice */ for (cur = start, i = 0; - cur < stop; + cur < (size_t)stop; cur += step, i++) { Py_ssize_t lim = step - 1; garbage[i] = PyList_GET_ITEM(self, cur); - if (cur + step >= Py_SIZE(self)) { + if (cur + step >= (size_t)Py_SIZE(self)) { lim = Py_SIZE(self) - cur - 1; } @@ -2473,7 +2474,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) lim * sizeof(PyObject *)); } cur = start + slicelength*step; - if (cur < Py_SIZE(self)) { + if (cur < (size_t)Py_SIZE(self)) { memmove(self->ob_item + cur - slicelength, self->ob_item + cur, (Py_SIZE(self) - cur) * |