summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2016-01-21 11:15:14 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2016-01-22 10:30:18 +0000
commit0b3851a02bfdf4a7c78901fdd1ab35ae1ca1e942 (patch)
treeaf18610f799394a38a0bd997f6942a6546e85b2c
parent3974c55e48057d94ecdee6dad9b2c0c5db8bf573 (diff)
Defer closing of PerfStdin until next event loop iteration
Closing a QIODevice on readData() can lead to crashes from QDataStream where the buffers are assumed to still be valid after any successful read. Change-Id: Ia5fa7b3d9b357954dbbb8769552e98899c9a0ede Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
-rw-r--r--app/perfstdin.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/perfstdin.cpp b/app/perfstdin.cpp
index a5d237c..8d4d2b0 100644
--- a/app/perfstdin.cpp
+++ b/app/perfstdin.cpp
@@ -19,6 +19,7 @@
****************************************************************************/
#include "perfstdin.h"
+#include <QTimer>
#include <cstdio>
#include <limits>
@@ -34,7 +35,7 @@ qint64 PerfStdin::readData(char *data, qint64 maxlen)
{
size_t read = fread(data, 1, maxlen, stdin);
if (feof(stdin) || ferror(stdin))
- close();
+ QTimer::singleShot(0, this, &QIODevice::close);
if (read == 0 && maxlen > 0) {
return -1;
} else {