diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-10 16:44:49 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-10 16:44:49 (GMT) |
| commit | f9a68be6733fba8b5003119445b08dedace9367e (patch) | |
| tree | 312a6ac27f43bf8bfae49503cb5f868af2356b9b /Python/specialize.c | |
| parent | 1de088ca95af7da6dbd1f4c715c178abd20170c4 (diff) | |
| download | cpython-f9a68be6733fba8b5003119445b08dedace9367e.zip cpython-f9a68be6733fba8b5003119445b08dedace9367e.tar.gz cpython-f9a68be6733fba8b5003119445b08dedace9367e.tar.bz2 | |
[3.11] GH-99257: Check the owner's type when specializing slots (GH-99324)
(cherry picked from commit 9d692841691590c25e6cf5b2250a594d3bf54825)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
Diffstat (limited to 'Python/specialize.c')
| -rw-r--r-- | Python/specialize.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index b318cb5..08ce2f5 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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; |
