Fix memory leak in alternative code route

If no oid is found, and x509_attr_descr_from_numericoid returns NULL,
previously the memory allocated for the oid wasn't freed.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
This commit is contained in:
Agathiyan Bragadeesh 2023-08-03 16:00:15 +01:00
parent f818e01edb
commit 39ba121d3a

View File

@ -139,6 +139,8 @@ static const x509_attr_descriptor_t *x509_attr_descr_from_numericoid(const char
ret = mbedtls_oid_from_numeric_string(oid, numericoid, numericoid_len);
if ((ret == MBEDTLS_ERR_X509_ALLOC_FAILED) || (ret == MBEDTLS_ERR_ASN1_INVALID_DATA)) {
mbedtls_free(oid->p);
mbedtls_free(oid);
return NULL;
}