-/* $OpenBSD: cms_lib.c,v 1.19 2023/07/28 10:28:02 tb Exp $ */
+/* $OpenBSD: cms_lib.c,v 1.20 2023/08/22 08:44:15 tb Exp $ */
/*
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
BIO *
CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
{
- BIO *cmsbio, *cont;
+ BIO *cmsbio = NULL, *cont = NULL;
- if (icont)
- cont = icont;
- else
+ if ((cont = icont) == NULL)
cont = cms_content_bio(cms);
- if (!cont) {
+ if (cont == NULL) {
CMSerror(CMS_R_NO_CONTENT);
- return NULL;
+ goto err;
}
switch (OBJ_obj2nid(cms->contentType)) {
default:
CMSerror(CMS_R_UNSUPPORTED_TYPE);
- return NULL;
+ goto err;
}
- if (cmsbio)
- return BIO_push(cmsbio, cont);
+ if (cmsbio == NULL)
+ goto err;
+
+ return BIO_push(cmsbio, cont);
- if (!icont)
+ err:
+ if (cont != icont)
BIO_free(cont);
return NULL;