diff --git a/src/x509.c b/src/x509.c index 9caf3a626..908448320 100644 --- a/src/x509.c +++ b/src/x509.c @@ -13965,7 +13965,9 @@ 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; + if (req->reqAttributes != NULL) { + req->reqAttributes->type = STACK_TYPE_X509_REQ_ATTR; + } } ret = wolfSSL_sk_push(req->reqAttributes, attr); }