From 2877b7be505c00f9472d53536b976a60be1b0504 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Tue, 24 Oct 2023 17:47:31 -0400 Subject: [PATCH] Fix possible memory leak --- src/x509.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x509.c b/src/x509.c index 0780601e4..0bf17ba8e 100644 --- a/src/x509.c +++ b/src/x509.c @@ -14098,7 +14098,8 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, } } ret = wolfSSL_sk_push(req->reqAttributes, attr); - if (ret != WOLFSSL_SUCCESS) { + if ((ret != WOLFSSL_SUCCESS) || (req->reqAttributes->type == STACK_TYPE_CIPHER)) { + /* CIPHER type makes a copy */ wolfSSL_X509_ATTRIBUTE_free(attr); } }