From 2d5462d77dc00e9f0a26f0df7a8fe3740adab456 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Mon, 29 Jul 2024 18:18:07 +0200 Subject: [PATCH] wolfSSL_X509_REQ_add1_attr_by_NID: clean up push call for analyzers --- src/x509.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/x509.c b/src/x509.c index 09c56dc8c3..d570f5ad6f 100644 --- a/src/x509.c +++ b/src/x509.c @@ -14517,11 +14517,12 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, req->reqAttributes->type = STACK_TYPE_X509_REQ_ATTR; } } - ret = wolfSSL_sk_push(req->reqAttributes, attr); - if ((ret != WOLFSSL_SUCCESS) || (req->reqAttributes->type == STACK_TYPE_CIPHER)) { - /* CIPHER type makes a copy */ + if (req->reqAttributes->type == STACK_TYPE_X509_REQ_ATTR) + ret = wolfSSL_sk_push(req->reqAttributes, attr); + else + ret = WOLFSSL_FAILURE; + if (ret != WOLFSSL_SUCCESS) wolfSSL_X509_ATTRIBUTE_free(attr); - } } return ret;