Add catch for alloc error x509_oid_from_numericoid
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
diff --git a/library/x509_create.c b/library/x509_create.c
index 46ffc9c..9d40db0 100644
--- a/library/x509_create.c
+++ b/library/x509_create.c
@@ -146,6 +146,11 @@
return NULL;
}
oid = mbedtls_calloc(1, oid_buf->len + 1);
+ if(oid == NULL) {
+ mbedtls_free(oid_buf->p);
+ mbedtls_free(oid_buf);
+ return MBEDTLS_ERR_X509_ALLOC_FAILED;
+ }
memcpy(oid, oid_buf->p, oid_buf->len);
oid[oid_buf->len + 1] = '\0';
mbedtls_free(oid_buf->p);