Fix error handling/cleanup

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4326)
This commit is contained in:
Rich Salz 2017-09-03 11:33:34 -04:00
parent 511fbc60d4
commit 180794c54e

View file

@ -473,19 +473,11 @@ static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * _intname,
int X509_NAME_set(X509_NAME **xn, X509_NAME *name) int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
{ {
X509_NAME *in; if ((name = X509_NAME_dup(name)) == NULL)
return 0;
if (!xn || !name) X509_NAME_free(*xn);
return (0); *xn = name;
return 1;
if (*xn != name) {
in = X509_NAME_dup(name);
if (in != NULL) {
X509_NAME_free(*xn);
*xn = in;
}
}
return (*xn != NULL);
} }
int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)