summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslcontext_openssl.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-01 19:36:36 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-03 09:55:02 +0100
commit2e271795e7c460254a27ea617846ff7b598a7b9b (patch)
tree9f34e6322a84fc6206f29741a746e5f45912c771 /src/network/ssl/qsslcontext_openssl.cpp
parente06f4c2558aaf99bd4ee0e13e9372c29418c5697 (diff)
QSslEllipticCurve: remove a copy when setting the curves
The only reason for copying QSslEllipticCurves into a temporary array would be to be extra-pedantic about type safety, but in the end, we can simply force a cast and remove the copy. Change-Id: Ice8a036fe4b79ba438ce83b5eacf6158eb3f0ce7 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/ssl/qsslcontext_openssl.cpp')
-rw-r--r--src/network/ssl/qsslcontext_openssl.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
index c1d09dce44..60573c4c83 100644
--- a/src/network/ssl/qsslcontext_openssl.cpp
+++ b/src/network/ssl/qsslcontext_openssl.cpp
@@ -340,11 +340,12 @@ init_context:
#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
// Set the curves to be used
if (q_SSLeay() >= 0x10002000L) {
- QVarLengthArray<int, 32> curves;
- foreach (const QSslEllipticCurve curve, qcurves)
- curves.append(curve.id);
-
- if (!q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_SET_CURVES, curves.size(), curves.data())) {
+ // SSL_CTX_ctrl wants a non-const pointer as last argument,
+ // but let's avoid a copy into a temporary array
+ if (!q_SSL_CTX_ctrl(sslContext->ctx,
+ SSL_CTRL_SET_CURVES,
+ qcurves.size(),
+ const_cast<int *>(reinterpret_cast<const int *>(qcurves.data())))) {
sslContext->errorStr = QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
sslContext->errorCode = QSslError::UnspecifiedError;
return sslContext;