From 1392fe1f6f56426056f65b2baccfb440dd420e13 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 9 Jun 2022 16:50:41 +0200 Subject: libshiboken: Fix a crash in Shiboken::Object::isValid() for Python 3.11 The function is passed type objects for class methods, which caused it to crash. The first clause did not catch this, and so it was cast to SbkObject below. Add a type check to prevent this. Task-number: PYSIDE-1960 Change-Id: Icfdd6fefb7156ac5961444bd5395109849a1d66e Reviewed-by: Christian Tismer Reviewed-by: Qt CI Bot (cherry picked from commit 52df3b8f64d08f412d7f8b12d82fc0ae6f3c741d) Reviewed-by: Qt Cherry-pick Bot --- sources/shiboken6/libshiboken/basewrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index b9d9b47ab..36801cd49 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -1277,6 +1277,7 @@ bool setCppPointer(SbkObject *sbkObj, PyTypeObject *desiredType, void *cptr) bool isValid(PyObject *pyObj) { if (!pyObj || pyObj == Py_None + || PyType_Check(pyObj) != 0 || Py_TYPE(Py_TYPE(pyObj)) != SbkObjectType_TypeF()) { return true; } -- cgit v1.2.3