Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 42024:b94f284805be legacy-trunk
Fix a bug when there was a newline in the string expandtabs was called on.
This also catches another condition that can overflow.
Will backport.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 11 Jun 2007 02:16:10 +0000 |
| parents | e62b606eff0b |
| children | 86d1dbfc5833 |
line wrap: on
line diff
--- a/Objects/stringobject.c Mon Jun 11 02:14:39 2007 +0000 +++ b/Objects/stringobject.c Mon Jun 11 02:16:10 2007 +0000 @@ -3322,7 +3322,8 @@ if (tabsize > 0) { j += tabsize - (j % tabsize); if (old_j > j) { - PyErr_SetString(PyExc_OverflowError, "new string is too long"); + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); return NULL; } old_j = j; @@ -3332,7 +3333,12 @@ j++; if (*p == '\n' || *p == '\r') { i += j; - j = 0; + old_j = j = 0; + if (i < 0) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } } }
