summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.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/stringobject.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/stringobject.c')
-rw-r--r--Objects/stringobject.c10
1 files changed, 8 insertions, 2 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;
+ }
}
}