summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-08-24 14:47:58 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-08-25 07:59:21 +0000
commit32fbcf71eef42a5f5f08400b469baddb1fcba10a (patch)
tree1bf5fd57ca02a01089179d8a0494a184ce0d92dc /tests
parent0b3509d85da168780ec8b2daf928c801d80ebe0a (diff)
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 <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp22
1 files 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<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
- setupSslServer(serverSocket);
- client = serverSocket;
- } else {
+ if (doSsl) {
+ QSslSocket *serverSocket = new QSslSocket(this);
+ if (!serverSocket->setSocketDescriptor(socketDescriptor)) {
delete serverSocket;
return;
}
+ connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
+ // connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready); ?
+ setupSslServer(serverSocket);
+ client = serverSocket;
+ } else
#endif
+ {
+ client = new QTcpSocket;
+ client->setSocketDescriptor(socketDescriptor);
}
connectSocketSignals();
client->setParent(this);