Skip to content

Commit 55abccd

Browse files
committed
Few nit picks
1 parent 1f3b8b8 commit 55abccd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_CertificateManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ HRESULT Library_sys_net_native_System_Net_Security_CertificateManager::GetDevice
9494
if (deviceCert)
9595
{
9696
X509RawData rawData;
97+
bool success = SSL_GetPublicKeyRaw((const char *)deviceCert->Certificate, deviceCert->CertificateSize, &rawData);
9798

98-
if (SSL_GetPublicKeyRaw((const char *)deviceCert->Certificate, deviceCert->CertificateSize, &rawData))
99+
platform_free(deviceCert);
100+
101+
if (success)
99102
{
100103
CLR_RT_HeapBlock_Array *array;
101104

@@ -108,8 +111,6 @@ HRESULT Library_sys_net_native_System_Net_Security_CertificateManager::GetDevice
108111

109112
platform_free(rawData.p);
110113
}
111-
112-
platform_free(deviceCert);
113114
}
114115

115116
NANOCLR_NOCLEANUP();

src/PAL/COM/sockets/ssl/MbedTLS/ssl_parse_certificate_internal.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ bool ssl_get_public_key_raw_internal(void *certificate, size_t size, void *x509R
6969

7070
x509->len = cacert.raw.len;
7171
x509->p = (unsigned char *)platform_malloc(x509->len);
72+
if (x509->p == NULL)
73+
{
74+
mbedtls_x509_crt_free(&cacert);
75+
return false;
76+
}
7277

7378
memcpy(x509->p, cacert.raw.p, x509->len);
7479

0 commit comments

Comments
 (0)