Check we're connected before startClientEncryption()
The docs say this is required, but we don't check it and instead segfault right now. Change-Id: I825b00a312a481c5383af127333c0c4698188348 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
This commit is contained in:
parent
47df122259
commit
2757a5fe8c
@ -1630,6 +1630,10 @@ void QSslSocket::startClientEncryption()
|
||||
qWarning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
|
||||
return;
|
||||
}
|
||||
if (state() != ConnectedState) {
|
||||
qWarning("QSslSocket::startClientEncryption: cannot start handshake when not connected");
|
||||
return;
|
||||
}
|
||||
#ifdef QSSLSOCKET_DEBUG
|
||||
qDebug() << "QSslSocket::startClientEncryption()";
|
||||
#endif
|
||||
|
@ -195,6 +195,7 @@ private slots:
|
||||
void setEmptyDefaultConfiguration();
|
||||
void versionAccessors();
|
||||
void sslOptions();
|
||||
void encryptWithoutConnecting();
|
||||
|
||||
static void exitLoop()
|
||||
{
|
||||
@ -2122,6 +2123,18 @@ void tst_QSslSocket::sslOptions()
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslSocket::encryptWithoutConnecting()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
"QSslSocket::startClientEncryption: cannot start handshake when not connected");
|
||||
|
||||
QSslSocket sock;
|
||||
sock.startClientEncryption();
|
||||
}
|
||||
|
||||
#endif // QT_NO_OPENSSL
|
||||
|
||||
QTEST_MAIN(tst_QSslSocket)
|
||||
|
Loading…
Reference in New Issue
Block a user