From 32fbcf71eef42a5f5f08400b469baddb1fcba10a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 24 Aug 2016 14:47:58 +0200 Subject: [PATCH] tst_qnetworkreply: restructure #if-ery round a condition If SSL was unavailable but requested (should never happen) MiniHttpServer::incomingConnection() would have crashed on dereferencing unset member client. Rework the run-time conditioning on SSL to sit entirely inside the #if-ery on SSL support, so that client is at least set in each code-path. Change-Id: I9a8ee8e4186e16dd0d00b7f9cc9b988f0b4c62ff Reviewed-by: Timur Pocheptsov --- .../qnetworkreply/tst_qnetworkreply.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8e370e193d..e3dd39b977 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -594,22 +594,22 @@ protected: void incomingConnection(qintptr socketDescriptor) { //qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6; - if (!doSsl) { - client = new QTcpSocket; - client->setSocketDescriptor(socketDescriptor); - } else { #ifndef QT_NO_SSL - QSslSocket *serverSocket = new QSslSocket; - serverSocket->setParent(this); - if (serverSocket->setSocketDescriptor(socketDescriptor)) { - connect(serverSocket, SIGNAL(sslErrors(QList)), this, SLOT(slotSslErrors(QList))); - setupSslServer(serverSocket); - client = serverSocket; - } else { + if (doSsl) { + QSslSocket *serverSocket = new QSslSocket(this); + if (!serverSocket->setSocketDescriptor(socketDescriptor)) { delete serverSocket; return; } + connect(serverSocket, SIGNAL(sslErrors(QList)), this, SLOT(slotSslErrors(QList))); + // connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready); ? + setupSslServer(serverSocket); + client = serverSocket; + } else #endif + { + client = new QTcpSocket; + client->setSocketDescriptor(socketDescriptor); } connectSocketSignals(); client->setParent(this);