From c161c6db780b308a604875c3e0f7affb09e89fce Mon Sep 17 00:00:00 2001 From: Romain Pokrzywka Date: Mon, 7 Aug 2017 12:12:31 -0500 Subject: 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 Reviewed-by: Laszlo Agocs --- src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp index 86f8a00b13..cfc17a79c3 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp @@ -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(buffer) + n, sizeof(buffer) - n); -- cgit v1.2.3