diff options
author | Vincent Richard <[email protected]> | 2007-12-23 16:19:39 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2007-12-23 16:19:39 +0000 |
commit | bc0e5a9a48740b1472404de0f4b78ec22fc1a7b2 (patch) | |
tree | 2f7362a6bd25b62ce8810b6bea6a9d5f647d6926 /src/net/tls/TLSSocket.cpp | |
parent | Fixed bug #1755458: The project generator does not exclude the SASL sources. ... (diff) | |
download | vmime-bc0e5a9a48740b1472404de0f4b78ec22fc1a7b2.tar.gz vmime-bc0e5a9a48740b1472404de0f4b78ec22fc1a7b2.zip |
Use std::vector<> instead of new[] allocation (avoid memory leaks by using RAII idiom).
Diffstat (limited to 'src/net/tls/TLSSocket.cpp')
-rw-r--r-- | src/net/tls/TLSSocket.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/net/tls/TLSSocket.cpp b/src/net/tls/TLSSocket.cpp index cc922796..fe5f2446 100644 --- a/src/net/tls/TLSSocket.cpp +++ b/src/net/tls/TLSSocket.cpp @@ -319,21 +319,19 @@ ref <security::cert::certificateChain> TLSSocket::getPeerCertificates() const gnutls_x509_crt_export(x509Certs[i], GNUTLS_X509_FMT_DER, NULL, &dataSize); - byte_t* data = new byte_t[dataSize]; + std::vector <byte_t> data(dataSize); gnutls_x509_crt_export(x509Certs[i], - GNUTLS_X509_FMT_DER, data, &dataSize); + GNUTLS_X509_FMT_DER, &data[0], &dataSize); ref <security::cert::X509Certificate> cert = - security::cert::X509Certificate::import(data, dataSize); + security::cert::X509Certificate::import(&data[0], dataSize); if (cert != NULL) certs.push_back(cert); else error = true; - delete [] data; - gnutls_x509_crt_deinit(x509Certs[i]); } |