mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
[3.13] gh-131998: Fix NULL
dereference when using an unbound method descriptor in a specialized code path (GH-132000) (#132262)
(cherry picked from commit ac3c439cdf
)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
a9bb0092d0
commit
5911768600
5 changed files with 41 additions and 0 deletions
|
@ -3686,12 +3686,14 @@ dummy_func(
|
|||
args--;
|
||||
total_args++;
|
||||
}
|
||||
DEOPT_IF(total_args == 0);
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
|
||||
PyMethodDef *meth = method->d_method;
|
||||
DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS));
|
||||
PyTypeObject *d_type = method->d_common.d_type;
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
DEOPT_IF(!Py_IS_TYPE(self, d_type));
|
||||
STAT_INC(CALL, hit);
|
||||
int nargs = total_args - 1;
|
||||
|
@ -3754,11 +3756,13 @@ dummy_func(
|
|||
total_args++;
|
||||
}
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
DEOPT_IF(total_args == 0);
|
||||
/* Builtin METH_FASTCALL methods, without keywords */
|
||||
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
|
||||
PyMethodDef *meth = method->d_method;
|
||||
DEOPT_IF(meth->ml_flags != METH_FASTCALL);
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
DEOPT_IF(!Py_IS_TYPE(self, method->d_common.d_type));
|
||||
STAT_INC(CALL, hit);
|
||||
PyCFunctionFast cfunc =
|
||||
|
|
10
Python/executor_cases.c.h
generated
10
Python/executor_cases.c.h
generated
|
@ -3817,6 +3817,10 @@
|
|||
args--;
|
||||
total_args++;
|
||||
}
|
||||
if (total_args == 0) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
if (!Py_IS_TYPE(method, &PyMethodDescr_Type)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
|
@ -3829,6 +3833,7 @@
|
|||
}
|
||||
PyTypeObject *d_type = method->d_common.d_type;
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
if (!Py_IS_TYPE(self, d_type)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
@ -3918,6 +3923,10 @@
|
|||
total_args++;
|
||||
}
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
if (total_args == 0) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
/* Builtin METH_FASTCALL methods, without keywords */
|
||||
if (!Py_IS_TYPE(method, &PyMethodDescr_Type)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
|
@ -3929,6 +3938,7 @@
|
|||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
if (!Py_IS_TYPE(self, method->d_common.d_type)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
|
4
Python/generated_cases.c.h
generated
4
Python/generated_cases.c.h
generated
|
@ -1627,11 +1627,13 @@
|
|||
total_args++;
|
||||
}
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
DEOPT_IF(total_args == 0, CALL);
|
||||
/* Builtin METH_FASTCALL methods, without keywords */
|
||||
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL);
|
||||
PyMethodDef *meth = method->d_method;
|
||||
DEOPT_IF(meth->ml_flags != METH_FASTCALL, CALL);
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
DEOPT_IF(!Py_IS_TYPE(self, method->d_common.d_type), CALL);
|
||||
STAT_INC(CALL, hit);
|
||||
PyCFunctionFast cfunc =
|
||||
|
@ -1676,12 +1678,14 @@
|
|||
args--;
|
||||
total_args++;
|
||||
}
|
||||
DEOPT_IF(total_args == 0, CALL);
|
||||
PyMethodDescrObject *method = (PyMethodDescrObject *)callable;
|
||||
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL);
|
||||
PyMethodDef *meth = method->d_method;
|
||||
DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL);
|
||||
PyTypeObject *d_type = method->d_common.d_type;
|
||||
PyObject *self = args[0];
|
||||
assert(self != NULL);
|
||||
DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL);
|
||||
STAT_INC(CALL, hit);
|
||||
int nargs = total_args - 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue