summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authormpage <mpage@meta.com>2024-08-21 12:16:30 (GMT)
committerGitHub <noreply@github.com>2024-08-21 12:16:30 (GMT)
commit50a595b37fe3201cd07701ffdda9d6baa6163562 (patch)
tree0b0f5a46b4789f96f8c2d18f037f398af965011f /Python
parent159db050f429da0bc847949b273ff25b8941943c (diff)
downloadcpython-50a595b37fe3201cd07701ffdda9d6baa6163562.zip
cpython-50a595b37fe3201cd07701ffdda9d6baa6163562.tar.gz
cpython-50a595b37fe3201cd07701ffdda9d6baa6163562.tar.bz2
[3.13] gh-122712: Guard against __code__ reassignment in CALL_ALLOC_AND_ENTER_INIT (GH-122713) (GH-123184)
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c2
-rw-r--r--Python/generated_cases.c.h2
2 files changed, 4 insertions, 0 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 1a41c7e..cac9f67 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -3407,6 +3407,8 @@ dummy_func(
PyFunctionObject *init = (PyFunctionObject *)cls->_spec_cache.init;
PyCodeObject *code = (PyCodeObject *)init->func_code;
DEOPT_IF(code->co_argcount != oparg+1);
+ DEOPT_IF((code->co_flags & (CO_VARKEYWORDS | CO_VARARGS | CO_OPTIMIZED)) != CO_OPTIMIZED);
+ DEOPT_IF(code->co_kwonlyargcount);
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize + _Py_InitCleanup.co_framesize));
STAT_INC(CALL, hit);
PyObject *self = _PyType_NewManagedObject(tp);
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 38a4c40..fe42e20 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -875,6 +875,8 @@
PyFunctionObject *init = (PyFunctionObject *)cls->_spec_cache.init;
PyCodeObject *code = (PyCodeObject *)init->func_code;
DEOPT_IF(code->co_argcount != oparg+1, CALL);
+ DEOPT_IF((code->co_flags & (CO_VARKEYWORDS | CO_VARARGS | CO_OPTIMIZED)) != CO_OPTIMIZED, CALL);
+ DEOPT_IF(code->co_kwonlyargcount, CALL);
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize + _Py_InitCleanup.co_framesize), CALL);
STAT_INC(CALL, hit);
PyObject *self = _PyType_NewManagedObject(tp);