Commit 0dfb9398 authored by Rich Salz's avatar Rich Salz
Browse files

free NULL cleanup



Start ensuring all OpenSSL "free" routines allow NULL, and remove
any if check before calling them.
This gets ASN1_OBJECT_free and ASN1_STRING_free.

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent 7c82e339
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -71,6 +71,11 @@
        Remove all but one '#ifdef undef' which is to be looked at.
     [Rich Salz]

  *) Clean up calling of xxx_free routines.
        Just like free(), fix most of the xxx_free routines to accept
        NULL.  Remove the non-null checks from callers.  Save much code.
     [Rich Salz]

  *) Experimental support for a new, fast, unbiased prime candidate generator,
     bn_probable_prime_dh_coprime(). Not currently used by any prime generator.
     [Felix Laurie von Massenbach <felix@erbridge.co.uk>]
+1 −2
Original line number Diff line number Diff line
@@ -1152,7 +1152,6 @@ int MAIN(int argc, char **argv)
        OPENSSL_free(secret_keyid);
    if (pwri_tmp)
        OPENSSL_free(pwri_tmp);
    if (econtent_type)
    ASN1_OBJECT_free(econtent_type);
    if (rr)
        CMS_ReceiptRequest_free(rr);
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
    return (ret);
 err:
    ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i);
    if ((ret != NULL) && ((a == NULL) || (*a != ret)))
    if ((a == NULL) || (*a != ret))
        ASN1_BIT_STRING_free(ret);
    return (NULL);
}
+2 −2
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
    return (ret);
 err:
    ASN1err(ASN1_F_C2I_ASN1_INTEGER, i);
    if ((ret != NULL) && ((a == NULL) || (*a != ret)))
    if ((a == NULL) || (*a != ret))
        ASN1_INTEGER_free(ret);
    return (NULL);
}
@@ -334,7 +334,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
    return (ret);
 err:
    ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i);
    if ((ret != NULL) && ((a == NULL) || (*a != ret)))
    if ((a == NULL) || (*a != ret))
        ASN1_INTEGER_free(ret);
    return (NULL);
}
+4 −4
Original line number Diff line number Diff line
@@ -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;
    }

    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;
}
Loading