diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-10-24 19:16:13 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2016-10-27 17:15:41 +0000 |
commit | 0e2d38b4477ffec6941d0f88cfa7bf92a8b79843 (patch) | |
tree | f4a71dca7c823aa5779e79d07c3e0ead7190d1f4 /src/network/socket/qnativesocketengine.cpp | |
parent | d19f01acbf9547762150a479793b84898f1a115e (diff) |
QAbstractSocket: avoid unspecified behavior in writing on TCP
Passing zero as size parameter to QAbstractSocketEngine::write() has
unspecified behavior, at least for TCP sockets. This could happen on
flush() when writeBuffer is empty or on writeData() with size 0. Avoid
by explicitly checking against zero size.
Change-Id: I070630d244ce6c3de3da94f84c2cded2c7a4b081
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/socket/qnativesocketengine.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 805acde860..86d13d82a2 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -846,6 +846,10 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, const Q /*! Writes a block of \a size bytes from \a data to the socket. Returns the number of bytes written, or -1 if an error occurred. + + Passing zero as the \a size parameter on a connected UDP socket + will send an empty datagram. For other socket types results are + unspecified. */ qint64 QNativeSocketEngine::write(const char *data, qint64 size) { |