diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-02 13:30:49 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-05 10:50:00 +0000 |
commit | 12db8b0a414603a46cb5b1c19151f6baa15b4bd7 (patch) | |
tree | ab06fa35cdab2ef53d2e5ffc140e8e33b138d996 | |
parent | d143ffd75c2d2c10b32abe92b5e1390f47f25ed7 (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.
Change-Id: Ie22cf81ebb0c390bb31684eadf19b682e4487361
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 7d6ea931fdc0d919ac9fa5ddadeb931c2578151f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/libshiboken/signature/signature.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp index 699488ec9..243f3e35f 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); |