From 39ba121d3a73d8987e6d5010fd9aab5967aac907 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Thu, 3 Aug 2023 16:00:15 +0100 Subject: [PATCH] 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 --- library/x509_create.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/x509_create.c b/library/x509_create.c index 8ce3584aee..dd47748ece 100644 --- a/library/x509_create.c +++ b/library/x509_create.c @@ -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; }