Ensure null pointers are not added to QXcbConnection::m_touchDevices
QXcbConnection::touchDeviceForId attempts to retrieve an existing XInput2TouchDeviceData from m_touchDevices via QHash::operator[]. If m_touchDevices does not contain the specified XInput2TouchDeviceData, QHash::operator[] adds a default constructed value (i.e. a null pointer) for the specified id. This null pointer is not removed from m_touchDevices if the condition "nrDevices <= 0" is true below. This causes a null pointer dereference later on in QXcbConnection::finalizeXInput2. Change-Id: Icd3352417047c4b35d56db2d9f51e3fa1d859e9d Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
315145ac95
commit
37e7c3afbc
@ -355,8 +355,11 @@ void QXcbConnection::xi2Select(xcb_window_t window)
|
|||||||
|
|
||||||
XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
|
XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
|
||||||
{
|
{
|
||||||
XInput2TouchDeviceData *dev = m_touchDevices[id];
|
XInput2TouchDeviceData *dev = Q_NULLPTR;
|
||||||
if (!dev) {
|
QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.find(id);
|
||||||
|
if ( devIt != m_touchDevices.end() ) {
|
||||||
|
dev = devIt.value();
|
||||||
|
} else {
|
||||||
int nrDevices = 0;
|
int nrDevices = 0;
|
||||||
QTouchDevice::Capabilities caps = 0;
|
QTouchDevice::Capabilities caps = 0;
|
||||||
dev = new XInput2TouchDeviceData;
|
dev = new XInput2TouchDeviceData;
|
||||||
@ -428,7 +431,6 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
|
|||||||
QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice);
|
QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice);
|
||||||
m_touchDevices[id] = dev;
|
m_touchDevices[id] = dev;
|
||||||
} else {
|
} else {
|
||||||
m_touchDevices.remove(id);
|
|
||||||
XIFreeDeviceInfo(dev->xiDeviceInfo);
|
XIFreeDeviceInfo(dev->xiDeviceInfo);
|
||||||
delete dev;
|
delete dev;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user