diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-04-08 16:55:39 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2016-04-30 13:13:26 +0000 |
commit | a4d26cf522b966056e47e47a004b7e4d668e3a2d (patch) | |
tree | 7e26cda8249fd557f411a030a05dfa2cb7ca4af5 /src/corelib/io/qwindowspipewriter_p.h | |
parent | c9f9f54d3f79915723270b2a6d06216a54c87433 (diff) |
QWindowsPipeWriter: ensure validity of the write buffer
QWindowsPipeWriter uses asynchronous API to perform writing. Once a cycle
has been started, the write buffer must remain valid until the write
operation is completed.
To avoid data corruption and possibly undefined behavior, this patch
makes QWindowsPipeWriter::write() take a QByteArray, which it keeps alive
for the duration of the write cycle.
Autotest-by: Thomas Hartmann
Task-number: QTBUG-52401
Change-Id: Ia35faee735c4e684267daa1f6bd689512b670cd2
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/corelib/io/qwindowspipewriter_p.h')
-rw-r--r-- | src/corelib/io/qwindowspipewriter_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index a78ab61adf..0228867522 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -47,6 +47,7 @@ #include <qelapsedtimer.h> #include <qobject.h> +#include <qbytearray.h> #include <qt_windows.h> QT_BEGIN_NAMESPACE @@ -106,7 +107,7 @@ public: explicit QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent = 0); ~QWindowsPipeWriter(); - qint64 write(const char *data, qint64 maxlen); + bool write(const QByteArray &ba); void stop(); bool waitForWrite(int msecs); bool isWriteOperationActive() const { return writeSequenceStarted; } @@ -136,6 +137,7 @@ private: HANDLE handle; Overlapped overlapped; + QByteArray buffer; qint64 numberOfBytesToWrite; qint64 pendingBytesWrittenValue; bool stopped; |