summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-06-11 04:32:41 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-06-11 04:32:41 (GMT)
commit8355dd58061649b64b253d6fdff3fd67ac3a4f49 (patch)
tree3b7e7d2a12d2e6431e8fb9bd6138b08d391fd5d0 /Objects/unicodeobject.c
parent11c5275c6129c2600a29111c9529d1e51aaf3cb6 (diff)
downloadcpython-8355dd58061649b64b253d6fdff3fd67ac3a4f49.zip
cpython-8355dd58061649b64b253d6fdff3fd67ac3a4f49.tar.gz
cpython-8355dd58061649b64b253d6fdff3fd67ac3a4f49.tar.bz2
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.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c10
1 files changed, 8 insertions, 2 deletions
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;
+ }
}
}