summaryrefslogtreecommitdiffstats
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorPeter Bierma <zintensitydev@gmail.com>2025-04-08 10:31:43 (GMT)
committerGitHub <noreply@github.com>2025-04-08 10:31:43 (GMT)
commitac3c439cdfee8452f2bcceacd67a1f4e423ac3cf (patch)
treed82077aabcc46b2186b32b25f3341dc0d9605188 /Python/generated_cases.c.h
parent3eda1460359c7e6af4c5b125a63388635a3ed477 (diff)
downloadcpython-ac3c439cdfee8452f2bcceacd67a1f4e423ac3cf.zip
cpython-ac3c439cdfee8452f2bcceacd67a1f4e423ac3cf.tar.gz
cpython-ac3c439cdfee8452f2bcceacd67a1f4e423ac3cf.tar.bz2
gh-131998: Fix `NULL` dereference when using an unbound method descriptor in a specialized code path (#132000)
Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index fa3de19..fb4ab92 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3333,6 +3333,11 @@
arguments--;
total_args++;
}
+ if (total_args == 0) {
+ UPDATE_MISS_STATS(CALL);
+ assert(_PyOpcode_Deopt[opcode] == (CALL));
+ JUMP_TO_PREDICTED(CALL);
+ }
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
if (!Py_IS_TYPE(method, &PyMethodDescr_Type)) {
UPDATE_MISS_STATS(CALL);
@@ -3346,6 +3351,7 @@
JUMP_TO_PREDICTED(CALL);
}
PyObject *self = PyStackRef_AsPyObjectBorrow(arguments[0]);
+ assert(self != NULL);
if (!Py_IS_TYPE(self, method->d_common.d_type)) {
UPDATE_MISS_STATS(CALL);
assert(_PyOpcode_Deopt[opcode] == (CALL));
@@ -3453,6 +3459,11 @@
arguments--;
total_args++;
}
+ if (total_args == 0) {
+ UPDATE_MISS_STATS(CALL);
+ assert(_PyOpcode_Deopt[opcode] == (CALL));
+ JUMP_TO_PREDICTED(CALL);
+ }
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
if (!Py_IS_TYPE(method, &PyMethodDescr_Type)) {
UPDATE_MISS_STATS(CALL);
@@ -3467,6 +3478,7 @@
}
PyTypeObject *d_type = method->d_common.d_type;
PyObject *self = PyStackRef_AsPyObjectBorrow(arguments[0]);
+ assert(self != NULL);
if (!Py_IS_TYPE(self, d_type)) {
UPDATE_MISS_STATS(CALL);
assert(_PyOpcode_Deopt[opcode] == (CALL));