free NULL cleanup
[openssl.git] / crypto / asn1 / a_utctm.c
index 2dac3b58b4c629063cc6638c602c7d839cb1e4aa..0e2f1b0c40b506c2331536ac15f8ba9ef5b5139e 100644 (file)
@@ -193,11 +193,11 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
     int free_s = 0;
 
     if (s == NULL) {
-        free_s = 1;
         s = ASN1_UTCTIME_new();
+        if (s == NULL)
+            goto err;
+        free_s = 1;
     }
-    if (s == NULL)
-        goto err;
 
     ts = OPENSSL_gmtime(&t, &data);
     if (ts == NULL)
@@ -233,7 +233,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
 #endif
     return (s);
  err:
-    if (free_s && s)
+    if (free_s)
         ASN1_UTCTIME_free(s);
     return NULL;
 }