Fix error handling/cleanup
authorRich Salz <rsalz@openssl.org>
Sun, 3 Sep 2017 15:33:34 +0000 (11:33 -0400)
committerRich Salz <rsalz@openssl.org>
Thu, 7 Sep 2017 20:01:07 +0000 (16:01 -0400)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4326)

crypto/x509/x_name.c

index 665a52082f8e5f7956789ec5759db93f4d21ae35..d36a9d37c16b970af1e9136552e1fb7cc4bd45bf 100644 (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 (!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;
 }
 
 int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
 }
 
 int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)