Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 39990:a9b1f404e88b 2.4
A review of overflow-detecting code in the 2.4 branch.
* unified the way intobject, longobject and mystrtoul handle
values around -sys.maxint-1.
* in general, trying to entierely avoid overflows in any computation
involving signed ints or longs is extremely involved. Fixed a few
simple cases where a compiler might be too clever (but that's all
guesswork).
* more overflow checks against bad data in marshal.c.
| author | Armin Rigo <arigo@tunes.org> |
|---|---|
| date | Wed, 04 Oct 2006 10:13:32 +0000 |
| parents | accfb156f9cc |
| children | f6bbe8d6fa33 |
line wrap: on
line diff
--- a/Objects/stringobject.c Wed Oct 04 09:18:51 2006 +0000 +++ b/Objects/stringobject.c Wed Oct 04 10:13:32 2006 +0000 @@ -799,7 +799,7 @@ register PyStringObject* op = (PyStringObject*) obj; size_t newsize = 2 + 4 * op->ob_size; PyObject *v; - if (newsize > INT_MAX) { + if (newsize > INT_MAX || newsize / 4 != op->ob_size) { PyErr_SetString(PyExc_OverflowError, "string is too large to make repr"); }
