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.
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 @@
 	    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 @@
             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;
+                }
             }
         }