diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-12-10 11:11:23 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-12-11 00:57:55 +0000 |
commit | 0908175a1aafe9131c501c3a653ba7621e701f80 (patch) | |
tree | 04d7b371d321c8d9723604bead50c6213d8afd8d /examples/network | |
parent | b99caf8f262dc2bcdf06b52405eeee08f37a886c (diff) |
secureudpclient - a speculative fix for non-reproducible crash
Not much information in a bug report: QByteArray is protected from negative
sizes and QUdpSocket too. FWIW - add one more check, similar to what
the server counterpart already had.
Fixes: QTBUG-83457
Change-Id: I585fa90e0a258d2257e4fed2f24c52b47548bcbb
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit b283ce1e836ab08e602a11ea255ee3d8e537902e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/network')
-rw-r--r-- | examples/network/secureudpclient/association.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/network/secureudpclient/association.cpp b/examples/network/secureudpclient/association.cpp index c950260078..59df94d5b9 100644 --- a/examples/network/secureudpclient/association.cpp +++ b/examples/network/secureudpclient/association.cpp @@ -112,6 +112,11 @@ void DtlsAssociation::udpSocketConnected() void DtlsAssociation::readyRead() { + if (socket.pendingDatagramSize() <= 0) { + emit warningMessage(tr("%1: spurious read notification?").arg(name)); + return; + } + //! [6] QByteArray dgram(socket.pendingDatagramSize(), Qt::Uninitialized); const qint64 bytesRead = socket.readDatagram(dgram.data(), dgram.size()); |