Fix QDBusInterface crashing with empty path on construction
On some machines having an empty path passed to QDBusInterface would cause a crash. This happened because the code created a QDBusMessage and manually marked it as validated when it was not. The validation would not pass for this object. Change-Id: I496dd922fa64353399655a1e84996b99990f5879 Pick-to: 6.4 6.3 6.2 5.15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2ba153dd5f
commit
4d60ba61dc
@ -2556,6 +2556,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
|
|||||||
if (mo)
|
if (mo)
|
||||||
return mo;
|
return mo;
|
||||||
}
|
}
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
error = QDBusError(QDBusError::InvalidObjectPath, "Object path cannot be empty"_L1);
|
||||||
|
lastError = error;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// introspect the target object
|
// introspect the target object
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
|
QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
|
||||||
|
@ -306,6 +306,13 @@ void tst_QDBusInterface::notValid()
|
|||||||
|
|
||||||
QVERIFY(!interface.isValid());
|
QVERIFY(!interface.isValid());
|
||||||
QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
|
QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
|
||||||
|
|
||||||
|
// With a connection, but empty/null service and path specified
|
||||||
|
QDBusConnection con = QDBusConnection::sessionBus();
|
||||||
|
QVERIFY(con.isConnected());
|
||||||
|
QDBusInterface iface({}, {}, {}, con);
|
||||||
|
QVERIFY(!iface.isValid());
|
||||||
|
QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDBusInterface::notValidDerived()
|
void tst_QDBusInterface::notValidDerived()
|
||||||
|
Loading…
Reference in New Issue
Block a user