xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 21 ++++------ 1 file changed, 10 insertions(+), 11 deletions(-)
New commits: commit eec04f7f0445d6aec03c0cf9745b61375b0000b1 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Apr 18 08:42:02 2017 +0200 loplugin:useuniqueptr (clang-cl) Change-Id: I32c69544b40c2398f415e3aaa9beb470694f0290 diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index 29e6d1d06a2f..8ae78b105403 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -31,6 +31,8 @@ #include <rtl/locale.h> #include <osl/nlsupport.h> #include <osl/process.h> + +#include <memory> #include <utility> #include <vector> #include <tools/time.hxx> @@ -214,17 +216,16 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { // Here the cbIssuer count the last 0x00 , take care. if( cbIssuer != 0 ) { - char* issuer = new char[ cbIssuer ] ; + auto issuer = std::unique_ptr<char[]>(new char[ cbIssuer ]); cbIssuer = CertNameToStr( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Issuer ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - issuer, cbIssuer + issuer.get(), cbIssuer ) ; if( cbIssuer <= 0 ) { - delete [] issuer ; throw RuntimeException() ; } @@ -234,9 +235,8 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { osl_getProcessLocale( &pLocale ) ; encoding = osl_getTextEncodingFromLocale( pLocale ) ; - if(issuer[cbIssuer-1] == 0) cbIssuer--; //delimit the last 0x00; - OUString xIssuer(issuer , cbIssuer ,encoding ) ; - delete [] issuer ; + if(issuer.get()[cbIssuer-1] == 0) cbIssuer--; //delimit the last 0x00; + OUString xIssuer(issuer.get() , cbIssuer ,encoding ) ; return replaceTagSWithTagST(xIssuer); } else { @@ -262,22 +262,21 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() if( cbSubject != 0 ) { - wchar_t* subject = new wchar_t[ cbSubject ] ; + auto subject = std::unique_ptr<wchar_t[]>(new wchar_t[ cbSubject ]); cbSubject = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Subject ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - subject, cbSubject + subject.get(), cbSubject ) ; if( cbSubject <= 0 ) { - delete [] subject ; throw RuntimeException() ; } - OUString xSubject(reinterpret_cast<const sal_Unicode*>(subject)); - delete [] subject ; + OUString xSubject( + reinterpret_cast<const sal_Unicode*>(subject.get())); return replaceTagSWithTagST(xSubject); } else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits