Common: cert util memory free fix

This is a bit of a style thing, as freeing a NULL pointer isn't
dangerous. Still, we hould only try to free the certificate name
if non-NULL, and then set it to NULL so it may not be accidentally
re-used if the code is later modified.
pull/165/head
Micah Snyder (micasnyd) 4 years ago
parent 8dd90c16b4
commit 8632035c9c
  1. 10
      common/cert_util.c
  2. 5
      common/mac/cert_util_mac.m

@ -579,7 +579,10 @@ void cert_fill_X509_store(X509_STORE *store, X509 **certs, size_t cert_count)
(name ? name : ""));
}
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
free(name);
if (NULL != name) {
free(name);
name = NULL;
}
#endif
}
}
@ -646,7 +649,10 @@ void cert_store_export_certs(X509_STORE *store, X509 *additional_ca_cert)
(name ? name : ""));
}
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
free(name);
if (NULL != name) {
free(name);
name = NULL;
}
#endif
}
} while (0);

@ -351,7 +351,10 @@ cl_error_t cert_store_load(X509 **trusted_certs, size_t trusted_cert_count)
mprintf("!Failed conversion of DER format to X.509\n");
}
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
free(name);
if (NULL != name) {
free(name);
name = NULL;
}
#endif
CFRelease(cert_data);

Loading…
Cancel
Save