Fix a race condition in QEvdevTabletHandler::readData()

Statics and threads don't mix well. There can be multiple threads
calling QEvdevTabletHandler::readData() simultaneously if you have
several tablet devices registered with the plugin, creating a race on
the static buffer array.

Make the buffer a simple local variable instead, the array is small
enough that we can afford the per-thread stack allocation.

Change-Id: I4487add8df50743b8178ca6faeb9be45231ccb78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Romain Pokrzywka 2017-08-07 12:12:31 -05:00
parent 9193b6cc85
commit c161c6db78
1 changed files with 1 additions and 1 deletions

View File

@ -246,7 +246,7 @@ bool QEvdevTabletHandler::queryLimits()
void QEvdevTabletHandler::readData()
{
static input_event buffer[32];
input_event buffer[32];
int n = 0;
for (; ;) {
int result = QT_READ(m_fd, reinterpret_cast<char*>(buffer) + n, sizeof(buffer) - n);