mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									ba965deea8
								
							
						
					
					
						commit
						5c9a81a3d8
					
				
					 3 changed files with 21 additions and 4 deletions
				
			
		|  | @ -5705,7 +5705,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; | ||||
|  | @ -5715,7 +5716,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; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Neal Norwitz
						Neal Norwitz