diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2023-03-21 12:32:28 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-21 16:19:31 +0000 |
commit | 44a471d346b76a9823f503e17f7d9bf39dfcf8e1 (patch) | |
tree | f3e743171c4b5b9425428206790085dbe6f8c951 | |
parent | 44926b9a0ffaa358caf5a5cfbf070756c3e3ad22 (diff) |
Move nullptr check to beginning of QInputDevice::operator<<
Nullptr check was performed after aquisition of the d-pointer.
That acquisition crashes if nullptr is passed to the operator, so the
actual check was never hit.
This patch moves the nullptr check to the beginning of the method.
Fixes: QTBUG-112174
Change-Id: If339e2de9ce2e33e10d925e79ca06b3854a24f76
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit f5c55da04bc53bcaf93bdb34588ef21af10333c6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/kernel/qinputdevice.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gui/kernel/qinputdevice.cpp b/src/gui/kernel/qinputdevice.cpp index 2098c3722e..0be5d4353e 100644 --- a/src/gui/kernel/qinputdevice.cpp +++ b/src/gui/kernel/qinputdevice.cpp @@ -373,19 +373,24 @@ bool QInputDevice::operator==(const QInputDevice &other) const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QInputDevice *device) { - const QInputDevicePrivate *d = QInputDevicePrivate::get(device); - if (d->pointingDeviceType) - return operator<<(debug, static_cast<const QPointingDevice *>(device)); QDebugStateSaver saver(debug); debug.nospace(); debug.noquote(); + debug << "QInputDevice("; - if (device) { - debug << '"' << device->name() << "\", type=" << device->type() - << Qt::hex << ", ID=" << device->systemId() << ", seat='" << device->seatName() << "'"; - } else { - debug << '0'; + if (!device) { + debug << "0)"; + return debug; } + + const QInputDevicePrivate *d = QInputDevicePrivate::get(device); + + if (d->pointingDeviceType) + return operator<<(debug, static_cast<const QPointingDevice *>(device)); + + debug << "QInputDevice("; + debug << '"' << device->name() << "\", type=" << device->type() + << Qt::hex << ", ID=" << device->systemId() << ", seat='" << device->seatName() << "'"; debug << ')'; return debug; } |