diff options
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/stringobject.c | 10 | ||||
| -rw-r--r-- | Objects/unicodeobject.c | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 8b54643..cee78a0 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3313,7 +3313,8 @@ string_expandtabs(PyStringObject *self, PyObject *args) 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 @@ string_expandtabs(PyStringObject *self, PyObject *args) 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; + } } } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0640da8..742db6f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5701,7 +5701,8 @@ unicode_expandtabs(PyUnicodeObject *self, PyObject *args) 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; @@ -5711,7 +5712,12 @@ unicode_expandtabs(PyUnicodeObject *self, PyObject *args) 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; + } } } |
