aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-06-09 16:50:41 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-06-11 09:24:37 +0200
commit8b8ebf358e42949159a815c8cc1ce1662fd15b54 (patch)
treea10da31a30a4b339cd797f0c454071ae463c7215
parentdfae9541544b64174738ff9383607d2040b2d2ff (diff)
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 <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 52df3b8f64d08f412d7f8b12d82fc0ae6f3c741d)
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 6ed64e562..9fbf64ecc 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -1508,6 +1508,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;
}