diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-02-26 14:52:47 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-02-27 10:11:30 (GMT) |
commit | 557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c (patch) | |
tree | 656e2b8567e3c12c115bd1922f6bddb43c18a811 /Source/cmSystemTools.cxx | |
parent | ab2d170c746d7cb68c39e9577cdaabc66668c0aa (diff) | |
download | CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.zip CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.tar.gz CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.tar.bz2 |
Modernize memory management
Update internals of various classes
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9127c50..d8cd705 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -25,6 +25,9 @@ #endif #if !defined(CMAKE_BOOTSTRAP) +# if defined(_WIN32) +# include <cm/memory> +# endif # include "cmCryptoHash.h" #endif @@ -908,7 +911,6 @@ std::string cmSystemTools::ComputeCertificateThumbprint( std::string thumbprint; #if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) - BYTE* certData = NULL; CRYPT_INTEGER_BLOB cryptBlob; HCERTSTORE certStore = NULL; PCCERT_CONTEXT certContext = NULL; @@ -920,12 +922,12 @@ std::string cmSystemTools::ComputeCertificateThumbprint( if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) { DWORD fileSize = GetFileSize(certFile, NULL); if (fileSize != INVALID_FILE_SIZE) { - certData = new BYTE[fileSize]; + auto certData = cm::make_unique<BYTE[]>(fileSize); if (certData != NULL) { DWORD dwRead = 0; - if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) { + if (ReadFile(certFile, certData.get(), fileSize, &dwRead, NULL)) { cryptBlob.cbData = fileSize; - cryptBlob.pbData = certData; + cryptBlob.pbData = certData.get(); // Verify that this is a valid cert if (PFXIsPFXBlob(&cryptBlob)) { @@ -961,7 +963,6 @@ std::string cmSystemTools::ComputeCertificateThumbprint( } } } - delete[] certData; } } CloseHandle(certFile); |