From 45fe3871f20e290e895fc101df8fb47b667a7fac Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 16 Jul 2024 11:29:33 +0300 Subject: [PATCH] gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792) (cherry picked from commit 8b6d4755812d0b02e9f26beb9c9a7714e4c5ac28) Co-authored-by: sobolevn --- Modules/_testcapi/vectorcall.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c index dcbc973c9fb991..bf91d0b423eb90 100644 --- a/Modules/_testcapi/vectorcall.c +++ b/Modules/_testcapi/vectorcall.c @@ -349,6 +349,9 @@ static PyObject * MethodDescriptor2_new(PyTypeObject* type, PyObject* args, PyObject *kw) { MethodDescriptor2Object *op = PyObject_New(MethodDescriptor2Object, type); + if (op == NULL) { + return NULL; + } op->base.vectorcall = NULL; op->vectorcall = MethodDescriptor_vectorcall; return (PyObject *)op;