mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848)
This commit is contained in:
		
							parent
							
								
									062cbb6772
								
							
						
					
					
						commit
						4013c17911
					
				
					 3 changed files with 24 additions and 5 deletions
				
			
		|  | @ -7211,7 +7211,7 @@ decode_code_page_errors(UINT code_page, | |||
|                          "in the target code page."; | ||||
|     /* each step cannot decode more than 1 character, but a character can be
 | ||||
|        represented as a surrogate pair */ | ||||
|     wchar_t buffer[2], *startout, *out; | ||||
|     wchar_t buffer[2], *out; | ||||
|     int insize; | ||||
|     Py_ssize_t outsize; | ||||
|     PyObject *errorHandler = NULL; | ||||
|  | @ -7248,7 +7248,7 @@ decode_code_page_errors(UINT code_page, | |||
|         *v = (PyObject*)_PyUnicode_New(size * Py_ARRAY_LENGTH(buffer)); | ||||
|         if (*v == NULL) | ||||
|             goto error; | ||||
|         startout = PyUnicode_AS_UNICODE(*v); | ||||
|         out = PyUnicode_AS_UNICODE(*v); | ||||
|     } | ||||
|     else { | ||||
|         /* Extend unicode object */ | ||||
|  | @ -7259,11 +7259,10 @@ decode_code_page_errors(UINT code_page, | |||
|         } | ||||
|         if (unicode_resize(v, n + size * Py_ARRAY_LENGTH(buffer)) < 0) | ||||
|             goto error; | ||||
|         startout = PyUnicode_AS_UNICODE(*v) + n; | ||||
|         out = PyUnicode_AS_UNICODE(*v) + n; | ||||
|     } | ||||
| 
 | ||||
|     /* Decode the byte string character per character */ | ||||
|     out = startout; | ||||
|     while (in < endin) | ||||
|     { | ||||
|         /* Decode a character */ | ||||
|  | @ -7318,7 +7317,7 @@ decode_code_page_errors(UINT code_page, | |||
|     *out = 0; | ||||
| 
 | ||||
|     /* Extend unicode object */ | ||||
|     outsize = out - startout; | ||||
|     outsize = out - PyUnicode_AS_UNICODE(*v); | ||||
|     assert(outsize <= PyUnicode_WSTR_LENGTH(*v)); | ||||
|     if (unicode_resize(v, outsize) < 0) | ||||
|         goto error; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka