mirror of
				https://github.com/python/cpython.git
				synced 2025-11-01 06:01:29 +00:00 
			
		
		
		
	Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
This commit is contained in:
		
							parent
							
								
									e1efc07a30
								
							
						
					
					
						commit
						1a1ff29659
					
				
					 15 changed files with 50 additions and 52 deletions
				
			
		|  | @ -556,7 +556,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k) | |||
|     /* Overallocate at most 10 characters. */ | ||||
|     space = (isize > 10 ? 10 : isize) + isize; | ||||
|     osize = space; | ||||
|     output = PyMem_Malloc(space * sizeof(Py_UCS4)); | ||||
|     output = PyMem_New(Py_UCS4, space); | ||||
|     if (!output) { | ||||
|         PyErr_NoMemory(); | ||||
|         return NULL; | ||||
|  | @ -703,7 +703,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k) | |||
|     /* We allocate a buffer for the output.
 | ||||
|        If we find that we made no changes, we still return | ||||
|        the NFD result. */ | ||||
|     output = PyMem_Malloc(len * sizeof(Py_UCS4)); | ||||
|     output = PyMem_New(Py_UCS4, len); | ||||
|     if (!output) { | ||||
|         PyErr_NoMemory(); | ||||
|         Py_DECREF(result); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka