diff --git a/src/internal.c b/src/internal.c index 50bf09b46..ee7184c30 100644 --- a/src/internal.c +++ b/src/internal.c @@ -4012,7 +4012,7 @@ void FreeX509(WOLFSSL_X509* x509) #endif /* OPENSSL_ALL */ #if defined(WOLFSSL_CERT_REQ) && defined(OPENSSL_ALL) if (x509->reqAttributes) { - wolfSSL_sk_free(x509->reqAttributes); + wolfSSL_sk_pop_free(x509->reqAttributes, NULL); } #endif /* WOLFSSL_CERT_REQ */ if (x509->altNames) { diff --git a/src/x509.c b/src/x509.c index 6959f2830..cf9899dc8 100644 --- a/src/x509.c +++ b/src/x509.c @@ -12342,6 +12342,7 @@ int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req, else { if (req->reqAttributes == NULL) { req->reqAttributes = wolfSSL_sk_new_node(req->heap); + req->reqAttributes->type = STACK_TYPE_X509_REQ_ATTR; } ret = wolfSSL_sk_push(req->reqAttributes, attr); }