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>
This commit is contained in:
Edward Welbourne 2016-08-24 14:47:58 +02:00
parent 0b3509d85d
commit 32fbcf71ee

View File

@ -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);