]> granicus.if.org Git - openssl/commitdiff
Fix error handling/cleanup
authorRich Salz <rsalz@openssl.org>
Thu, 7 Sep 2017 20:17:06 +0000 (16:17 -0400)
committerRich Salz <rsalz@openssl.org>
Thu, 7 Sep 2017 20:18:04 +0000 (16:18 -0400)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4326)
(cherry picked from commit 180794c54e98ae467c4ebced3737e1ede03e320a)

crypto/asn1/x_name.c

index 1fb7ad1cbf88afc7c8f93f3f26598360da5f755a..aea0c2763c28fad69b4a327891b4a5b9e8373642 100644 (file)
@@ -523,19 +523,11 @@ static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * _intname,
 
 int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
 {
-    X509_NAME *in;
-
-    if (!xn || !name)
-        return (0);
-
-    if (*xn != name) {
-        in = X509_NAME_dup(name);
-        if (in != NULL) {
-            X509_NAME_free(*xn);
-            *xn = in;
-        }
-    }
-    return (*xn != NULL);
+    if ((name = X509_NAME_dup(name)) == NULL)
+        return 0;
+    X509_NAME_free(*xn);
+    *xn = name;
+    return 1;
 }
 
 IMPLEMENT_STACK_OF(X509_NAME_ENTRY)