Fix a python plugin crash when trying to login with empty credentials
This commit is contained in:
parent
5674ba7567
commit
fc8c9df40e
@ -505,8 +505,9 @@ void PythonIntegrationPlugin::confirmPairing(ThingPairingInfo *info, const QStri
|
|||||||
PyEval_ReleaseThread(m_threadState);
|
PyEval_ReleaseThread(m_threadState);
|
||||||
});
|
});
|
||||||
|
|
||||||
PyObject *pyUsername = PyUnicode_FromString(username.toUtf8().data());
|
// PyUnicode_FromString crashes on empty strings. Creating a new empty python string instead.
|
||||||
PyObject *pySecret = PyUnicode_FromString(secret.toUtf8().data());
|
PyObject *pyUsername = username.isEmpty() ? PyUnicode_New(1, 127) : PyUnicode_FromString(username.toUtf8().data());
|
||||||
|
PyObject *pySecret = secret.isEmpty() ? PyUnicode_New(1, 127) : PyUnicode_FromString(secret.toUtf8().data());
|
||||||
bool result = callPluginFunction("confirmPairing", reinterpret_cast<PyObject*>(pyInfo), pyUsername, pySecret);
|
bool result = callPluginFunction("confirmPairing", reinterpret_cast<PyObject*>(pyInfo), pyUsername, pySecret);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
info->finish(Thing::ThingErrorHardwareFailure, "Plugin error: " + pluginName());
|
info->finish(Thing::ThingErrorHardwareFailure, "Plugin error: " + pluginName());
|
||||||
|
|||||||
Reference in New Issue
Block a user