diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-02-14 13:08:35 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-02-14 13:08:35 +0000 |
commit | a920961673c5589ca8aae6652b1563a651daf80f (patch) | |
tree | 183144afd8af5610755ce69c45ea997ba19fdd62 /Objects/bytearrayobject.c | |
parent | 71e38f57f365e3bdeafd5c6c2ed7d45de856b026 (diff) | |
download | cpython-git-a920961673c5589ca8aae6652b1563a651daf80f.tar.gz |
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/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index a634cff27b..15b09ba1e7 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -713,7 +713,7 @@ bytes_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values) i < slicelen; cur += step, i++) { Py_ssize_t lim = step - 1; - if (cur + step >= PyByteArray_GET_SIZE(self)) + if (cur + step >= (size_t)PyByteArray_GET_SIZE(self)) lim = PyByteArray_GET_SIZE(self) - cur - 1; memmove(self->ob_bytes + cur - i, @@ -721,7 +721,7 @@ bytes_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values) } /* Move the tail of the bytes, in one chunk */ cur = start + slicelen*step; - if (cur < PyByteArray_GET_SIZE(self)) { + if (cur < (size_t)PyByteArray_GET_SIZE(self)) { memmove(self->ob_bytes + cur - slicelen, self->ob_bytes + cur, PyByteArray_GET_SIZE(self) - cur); @@ -921,13 +921,14 @@ bytes_repr(PyByteArrayObject *self) const char *quote_postfix = ")"; Py_ssize_t length = Py_SIZE(self); /* 14 == strlen(quote_prefix) + 2 + strlen(quote_postfix) */ - size_t newsize = 14 + 4 * length; + size_t newsize; PyObject *v; - if (newsize > PY_SSIZE_T_MAX || newsize / 4 - 3 != length) { + if (length > (PY_SSIZE_T_MAX - 14) / 4) { PyErr_SetString(PyExc_OverflowError, "bytearray object is too large to make repr"); return NULL; } + newsize = 14 + 4 * length; v = PyUnicode_FromUnicode(NULL, newsize); if (v == NULL) { return NULL; |