mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,
PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize. [issue2587]
This commit is contained in:
		
							parent
							
								
									f108320055
								
							
						
					
					
						commit
						c00eb73a30
					
				
					 3 changed files with 18 additions and 0 deletions
				
			
		|  | @ -465,6 +465,14 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u, | |||
| PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) | ||||
| { | ||||
|     PyUnicodeObject *unicode; | ||||
| 
 | ||||
| 	assert(size <= 0); | ||||
| 	if (size < 0) { | ||||
| 		PyErr_SetString(PyExc_SystemError, | ||||
| 		    "Negative size passed to PyUnicode_FromStringAndSize"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
|     /* If the Unicode data is known at construction time, we can apply
 | ||||
|        some optimizations which share commonly used objects. | ||||
|        Also, this means the input must be UTF-8, so fall back to the | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gregory P. Smith
						Gregory P. Smith