static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid,
int crit, void *ext_struc)
{
- unsigned char *ext_der;
+ unsigned char *ext_der = NULL;
int ext_len;
- ASN1_OCTET_STRING *ext_oct;
+ ASN1_OCTET_STRING *ext_oct = NULL;
X509_EXTENSION *ext;
/* Convert internal representation to DER */
if (method->it)
}
if (!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr;
ext_oct->data = ext_der;
+ ext_der = NULL;
ext_oct->length = ext_len;
ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
merr:
X509V3err(X509V3_F_DO_EXT_I2D,ERR_R_MALLOC_FAILURE);
+ if (ext_der != NULL)
+ OPENSSL_free(ext_der);
+ if (ext_oct != NULL)
+ M_ASN1_OCTET_STRING_free(ext_oct);
return NULL;
}