mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.11] GH-99257: Check the owner's type when specializing slots (GH-99324)
(cherry picked from commit 9d69284169)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
			
			
This commit is contained in:
		
							parent
							
								
									1de088ca95
								
							
						
					
					
						commit
						f9a68be673
					
				
					 3 changed files with 78 additions and 0 deletions
				
			
		|  | @ -688,6 +688,10 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name) | |||
|             PyMemberDescrObject *member = (PyMemberDescrObject *)descr; | ||||
|             struct PyMemberDef *dmem = member->d_member; | ||||
|             Py_ssize_t offset = dmem->offset; | ||||
|             if (!PyObject_TypeCheck(owner, member->d_common.d_type)) { | ||||
|                 SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_EXPECTED_ERROR); | ||||
|                 goto fail; | ||||
|             } | ||||
|             if (dmem->flags & PY_AUDIT_READ) { | ||||
|                 SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_AUDITED_SLOT); | ||||
|                 goto fail; | ||||
|  | @ -777,6 +781,10 @@ _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name) | |||
|             PyMemberDescrObject *member = (PyMemberDescrObject *)descr; | ||||
|             struct PyMemberDef *dmem = member->d_member; | ||||
|             Py_ssize_t offset = dmem->offset; | ||||
|             if (!PyObject_TypeCheck(owner, member->d_common.d_type)) { | ||||
|                 SPECIALIZATION_FAIL(STORE_ATTR, SPEC_FAIL_EXPECTED_ERROR); | ||||
|                 goto fail; | ||||
|             } | ||||
|             if (dmem->flags & READONLY) { | ||||
|                 SPECIALIZATION_FAIL(STORE_ATTR, SPEC_FAIL_ATTR_READ_ONLY); | ||||
|                 goto fail; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)