summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-06-11 02:16:10 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-06-11 02:16:10 (GMT)
commit5c9a81a3d828e775a1500bb8d84dc1dab59513ad (patch)
tree868a2214eae0f4ac5f30719a835a63d730fcfff8 /Objects/stringobject.c
parentba965deea89299611454e43be005df357b75b11d (diff)
downloadcpython-5c9a81a3d828e775a1500bb8d84dc1dab59513ad.zip
cpython-5c9a81a3d828e775a1500bb8d84dc1dab59513ad.tar.gz
cpython-5c9a81a3d828e775a1500bb8d84dc1dab59513ad.tar.bz2
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.
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 d7ad5cc..3870343 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -3322,7 +3322,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;
@@ -3332,7 +3333,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;
+ }
}
}