aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-02 13:30:49 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-05 09:38:27 +0100
commit7d6ea931fdc0d919ac9fa5ddadeb931c2578151f (patch)
tree5ed21acf5c93c08e10026bfe7b9df9a9639154c9
parent559162e3c8126457b4d36f4b4a67e73971a06b8e (diff)
Handle crash when passing arguments of wrong type in embedded application
When passing arguments of wrong type in the scriptableapplication example, PyRun_String() fails and a crash occurs (NameError: name 'AppLib' is not defined). Catch this and return nullptr to get at an error message. Pick-to: 6.2 5.15 Change-Id: Ie22cf81ebb0c390bb31684eadf19b682e4487361 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index d6d99ec2c..e656e38e4 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -513,6 +513,9 @@ static PyObject *adjustFuncName(const char *func_name)
// Run `eval` on the type string to get the object.
AutoDecRef obtype(PyRun_String(_path, Py_eval_input, ns, ns));
+ if (obtype.isNull())
+ return nullptr;
+
if (PyModule_Check(obtype.object())) {
// This is a plain function. Return the unmangled name.
return String::fromCString(func_name);