Commit 25aaa98a authored by Rich Salz's avatar Rich Salz
Browse files

free NULL cleanup -- coda



After the finale, the "real" final part. :)  Do a recursive grep with
"-B1 -w [a-zA-Z0-9_]*_free" to see if any of the preceeding lines are
an "if NULL" check that can be removed.

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent 66696478
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -592,11 +592,8 @@ int load_cert_crl_http(const char *url, X509 **pcert, X509_CRL **pcrl)
    }

 err:
    if (host)
    OPENSSL_free(host);
    if (path)
    OPENSSL_free(path);
    if (port)
    OPENSSL_free(port);
    if (bio)
        BIO_free_all(bio);
@@ -660,7 +657,6 @@ X509 *load_cert(const char *file, int format,
        BIO_printf(bio_err, "unable to load certificate\n");
        ERR_print_errors(bio_err);
    }
    if (cert != NULL)
    BIO_free(cert);
    return (x);
}
@@ -761,7 +757,6 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
        goto end;
    }
 end:
    if (key != NULL)
    BIO_free(key);
    if (pkey == NULL) {
        BIO_printf(bio_err, "unable to load %s\n", key_descrip);
@@ -849,7 +844,6 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
        pkey = b2i_PublicKey_bio(key);
#endif
 end:
    if (key != NULL)
    BIO_free(key);
    if (pkey == NULL)
        BIO_printf(bio_err, "unable to load %s\n", key_descrip);
+2 −4
Original line number Diff line number Diff line
@@ -319,14 +319,12 @@ int asn1parse_main(int argc, char **argv)
    BIO_free(b64);
    if (ret != 0)
        ERR_print_errors(bio_err);
    if (buf != NULL)
    BUF_MEM_free(buf);
    OPENSSL_free(name);
    OPENSSL_free(header);
    if (strictpem)
        OPENSSL_free(str);
    ASN1_TYPE_free(at);
    if (osk != NULL)
    sk_OPENSSL_STRING_free(osk);
    OBJ_cleanup();
    return (ret);
+8 −15
Original line number Diff line number Diff line
@@ -514,10 +514,8 @@ end_of_options:
                       errorline, configfile);
        goto end;
    }
    if (tofree) {
    OPENSSL_free(tofree);
    tofree = NULL;
    }

    /* Lets get the config section we are using */
    if (section == NULL) {
@@ -1331,7 +1329,6 @@ end_of_options:
        /*****************************************************************/
    ret = 0;
 end:
    if (tofree)
    OPENSSL_free(tofree);
    BIO_free_all(Cout);
    BIO_free_all(Sout);
@@ -1342,12 +1339,11 @@ end_of_options:
    if (ret)
        ERR_print_errors(bio_err);
    app_RAND_write_file(randfile);
    if (free_key && key)
    if (free_key)
        OPENSSL_free(key);
    BN_free(serial);
    BN_free(crlnumber);
    free_index(db);
    if (sigopts)
    sk_OPENSSL_STRING_free(sigopts);
    EVP_PKEY_free(pkey);
    X509_free(x509);
@@ -2000,7 +1996,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
    ok = 1;
 end:
    for (i = 0; i < DB_NUMBER; i++)
        if (row[i] != NULL)
        OPENSSL_free(row[i]);

    X509_NAME_free(CAname);
@@ -2159,9 +2154,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey,
                 ext_copy, 0);
 end:
    X509_REQ_free(req);
    if (parms != NULL)
    CONF_free(parms);
    if (spki != NULL)
    NETSCAPE_SPKI_free(spki);
    X509_NAME_ENTRY_free(ne);

+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ int ciphers_main(int argc, char **argv)
 err:
    ERR_print_errors(bio_err);
 end:
    if (use_supported && sk)
    if (use_supported)
        sk_SSL_CIPHER_free(sk);
    SSL_CTX_free(ctx);
    SSL_free(ssl);
+9 −18
Original line number Diff line number Diff line
@@ -1117,19 +1117,14 @@ int cms_main(int argc, char **argv)
    sk_X509_pop_free(encerts, X509_free);
    sk_X509_pop_free(other, X509_free);
    X509_VERIFY_PARAM_free(vpm);
    if (sksigners)
    sk_OPENSSL_STRING_free(sksigners);
    if (skkeys)
    sk_OPENSSL_STRING_free(skkeys);
    OPENSSL_free(secret_key);
    OPENSSL_free(secret_keyid);
    OPENSSL_free(pwri_tmp);
    ASN1_OBJECT_free(econtent_type);
    if (rr)
    CMS_ReceiptRequest_free(rr);
    if (rr_to)
    sk_OPENSSL_STRING_free(rr_to);
    if (rr_from)
    sk_OPENSSL_STRING_free(rr_from);
    for (key_param = key_first; key_param;) {
        cms_key_param *tparam;
@@ -1247,7 +1242,6 @@ static void receipt_request_print(CMS_ContentInfo *cms)
            BIO_puts(bio_err, "  Receipts To:\n");
            gnames_stack_print(rto);
        }
        if (rr)
        CMS_ReceiptRequest_free(rr);
    }
}
@@ -1280,11 +1274,8 @@ static STACK_OF(GENERAL_NAMES) *make_names_stack(STACK_OF(OPENSSL_STRING) *ns)
    return ret;

 err:
    if (ret)
    sk_GENERAL_NAMES_pop_free(ret, GENERAL_NAMES_free);
    if (gens)
    GENERAL_NAMES_free(gens);
    if (gen)
    GENERAL_NAME_free(gen);
    return NULL;
}
Loading