Fix error paths in ASN1_TIME_to_generalizedtime
authorMatt Caswell <matt@openssl.org>
Tue, 21 Mar 2017 09:07:17 +0000 (09:07 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 21 Mar 2017 14:07:50 +0000 (14:07 +0000)
We should not write to |out| in error cases, so we should defer doing this
until the "done" block.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3002)

crypto/asn1/a_time.c

index 607432581686473fd971c4372b8c66b599a2cafc..0eeb79cd428ce02abac433aaad6126682787f495 100644 (file)
@@ -147,10 +147,9 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
     if (!out || !*out) {
         if (!(ret = ASN1_GENERALIZEDTIME_new()))
             goto err;
-        if (out)
-            *out = ret;
-    } else
+    } else {
         ret = *out;
+    }
 
     /* If already GeneralizedTime just copy across */
     if (t->type == V_ASN1_GENERALIZEDTIME) {