diff --git a/src/plugins/tls/schannel/qx509_schannel.cpp b/src/plugins/tls/schannel/qx509_schannel.cpp index 47d11b82551..1c4e96b25c8 100644 --- a/src/plugins/tls/schannel/qx509_schannel.cpp +++ b/src/plugins/tls/schannel/qx509_schannel.cpp @@ -16,11 +16,7 @@ namespace QTlsPrivate { X509CertificateSchannel::X509CertificateSchannel() = default; -X509CertificateSchannel::~X509CertificateSchannel() -{ - if (certificateContext) - CertFreeCertificateContext(certificateContext); -} +X509CertificateSchannel::~X509CertificateSchannel() = default; TlsKey *X509CertificateSchannel::publicKey() const { @@ -33,7 +29,7 @@ TlsKey *X509CertificateSchannel::publicKey() const Qt::HANDLE X509CertificateSchannel::handle() const { - return Qt::HANDLE(certificateContext); + return Qt::HANDLE(certificateContext.get()); } QSslCertificate X509CertificateSchannel::QSslCertificate_from_CERT_CONTEXT(const CERT_CONTEXT *certificateContext) @@ -44,7 +40,7 @@ QSslCertificate X509CertificateSchannel::QSslCertificate_from_CERT_CONTEXT(const if (!certificate.isNull()) { auto *certBackend = QTlsBackend::backend(certificate); Q_ASSERT(certBackend); - certBackend->certificateContext = CertDuplicateCertificateContext(certificateContext); + certBackend->certificateContext.reset(CertDuplicateCertificateContext(certificateContext)); } return certificate; } diff --git a/src/plugins/tls/schannel/qx509_schannel_p.h b/src/plugins/tls/schannel/qx509_schannel_p.h index 4625c9584cc..caf2a914f65 100644 --- a/src/plugins/tls/schannel/qx509_schannel_p.h +++ b/src/plugins/tls/schannel/qx509_schannel_p.h @@ -41,7 +41,7 @@ public: QList *caCertificates, const QByteArray &passPhrase); private: - const CERT_CONTEXT *certificateContext = nullptr; + QPCCertContextPointer certificateContext; Q_DISABLE_COPY_MOVE(X509CertificateSchannel); };