diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index 4288571d..06658b07 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -64,6 +64,12 @@ int X509_set_version(X509 *x, long version) { if (x == NULL) return(0); + if (version == 0) + { + M_ASN1_INTEGER_free(x->cert_info->version); + x->cert_info->version = NULL; + return(1); + } if (x->cert_info->version == NULL) { if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL)