Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 42027:71f3192915e1 2.5
Backport 55874:
Fix a bug when there was a newline in the string expandtabs was called on.
This also catches another condition that can overflow.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 11 Jun 2007 04:32:41 +0000 |
| parents | 2bd9417dacd5 |
| children | b43e5f3348ae |
line wrap: on
line diff
--- a/Objects/stringobject.c Mon Jun 11 04:31:25 2007 +0000 +++ b/Objects/stringobject.c Mon Jun 11 04:32:41 2007 +0000 @@ -3313,7 +3313,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; @@ -3323,7 +3324,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; + } } }
