free null cleanup finale
authorRich Salz <rsalz@openssl.org>
Fri, 1 May 2015 14:02:07 +0000 (10:02 -0400)
committerRich Salz <rsalz@openssl.org>
Fri, 1 May 2015 14:02:07 +0000 (10:02 -0400)
Don't check for NULL before calling OPENSSL_free

Reviewed-by: Richard Levitte <levitte@openssl.org>
173 files changed:
apps/apps.c
apps/asn1pars.c
apps/ca.c
apps/cms.c
apps/dgst.c
apps/dsa.c
apps/ec.c
apps/ecparam.c
apps/enc.c
apps/engine.c
apps/gendsa.c
apps/genpkey.c
apps/genrsa.c
apps/ocsp.c
apps/openssl.c
apps/passwd.c
apps/pkcs12.c
apps/pkcs8.c
apps/pkey.c
apps/pkeyutl.c
apps/req.c
apps/rsa.c
apps/rsautl.c
apps/s_client.c
apps/s_server.c
apps/s_socket.c
apps/smime.c
apps/speed.c
apps/spkac.c
apps/srp.c
apps/x509.c
crypto/asn1/a_bitstr.c
crypto/asn1/a_enum.c
crypto/asn1/a_gentm.c
crypto/asn1/a_int.c
crypto/asn1/a_mbstr.c
crypto/asn1/a_object.c
crypto/asn1/a_sign.c
crypto/asn1/a_utctm.c
crypto/asn1/ameth_lib.c
crypto/asn1/asn1_gen.c
crypto/asn1/asn1_lib.c
crypto/asn1/asn_mime.c
crypto/asn1/asn_pack.c
crypto/asn1/bio_asn1.c
crypto/asn1/bio_ndef.c
crypto/asn1/f_enum.c
crypto/asn1/f_int.c
crypto/asn1/f_string.c
crypto/asn1/t_x509.c
crypto/asn1/tasn_dec.c
crypto/asn1/tasn_prn.c
crypto/asn1/tasn_scn.c
crypto/asn1/tasn_utl.c
crypto/asn1/x_info.c
crypto/asn1/x_pkey.c
crypto/asn1/x_pubkey.c
crypto/asn1/x_x509.c
crypto/bio/b_sock.c
crypto/bio/bf_buff.c
crypto/bio/bf_lbuf.c
crypto/bio/bf_nbio.c
crypto/bio/bss_acpt.c
crypto/bio/bss_bio.c
crypto/bio/bss_conn.c
crypto/bio/bss_dgram.c
crypto/bn/bn_exp.c
crypto/bn/bn_gf2m.c
crypto/bn/bn_intern.c
crypto/bn/bn_lib.c
crypto/bn/bn_print.c
crypto/bn/bn_rand.c
crypto/cms/cms_env.c
crypto/cms/cms_ess.c
crypto/cms/cms_kari.c
crypto/cms/cms_pwri.c
crypto/cms/cms_sd.c
crypto/comp/c_zlib.c
crypto/conf/conf_api.c
crypto/conf/conf_def.c
crypto/conf/conf_mod.c
crypto/dh/dh_ameth.c
crypto/dh/dh_kdf.c
crypto/dh/dh_lib.c
crypto/dh/dh_pmeth.c
crypto/dsa/dsa_ameth.c
crypto/dsa/dsa_gen.c
crypto/dsa/dsa_pmeth.c
crypto/dso/dso_dl.c
crypto/dso/dso_dlfcn.c
crypto/dso/dso_lib.c
crypto/dso/dso_vms.c
crypto/dso/dso_win32.c
crypto/ec/ec_ameth.c
crypto/ec/ec_asn1.c
crypto/ec/ec_lib.c
crypto/ec/ec_mult.c
crypto/ec/ec_pmeth.c
crypto/ec/eck_prn.c
crypto/ec/ecp_nistp224.c
crypto/ec/ecp_nistp256.c
crypto/ec/ecp_nistp521.c
crypto/ec/ecp_nistz256.c
crypto/ecdh/ech_ossl.c
crypto/engine/eng_cryptodev.c
crypto/engine/eng_dyn.c
crypto/err/err.c
crypto/evp/evp_enc.c
crypto/ex_data.c
crypto/mem.c
crypto/objects/obj_dat.c
crypto/objects/obj_lib.c
crypto/ocsp/ocsp_ext.c
crypto/ocsp/ocsp_ht.c
crypto/ocsp/ocsp_lib.c
crypto/pem/pem_info.c
crypto/pem/pem_seal.c
crypto/pem/pem_sign.c
crypto/pem/pvkfmt.c
crypto/pkcs7/pk7_doit.c
crypto/rsa/rsa_ameth.c
crypto/rsa/rsa_oaep.c
crypto/rsa/rsa_pk1.c
crypto/rsa/rsa_pmeth.c
crypto/rsa/rsa_pss.c
crypto/stack/stack.c
crypto/store/str_mem.c
crypto/threads/th-lock.c
crypto/txt_db/txt_db.c
crypto/ui/ui_lib.c
crypto/x509/by_dir.c
crypto/x509/x509_vpm.c
crypto/x509/x509spki.c
crypto/x509/x_name.c
crypto/x509v3/v3_conf.c
crypto/x509v3/v3_prn.c
crypto/x509v3/v3_scts.c
crypto/x509v3/v3_utl.c
demos/b64.c
demos/engines/zencod/hw_zencod.c
engines/ccgost/gost_ameth.c
engines/ccgost/gost_ctl.c
engines/ccgost/gost_pmeth.c
engines/e_4758cca.c
engines/e_aep.c
engines/e_atalla.c
engines/e_capi.c
engines/e_chil.c
engines/e_cswift.c
engines/e_nuron.c
engines/e_ubsec.c
ssl/bio_ssl.c
ssl/d1_both.c
ssl/record/rec_layer_d1.c
ssl/record/ssl3_buffer.c
ssl/record/ssl3_record.c
ssl/s3_clnt.c
ssl/s3_lib.c
ssl/s3_srvr.c
ssl/ssl_asn1.c
ssl/ssl_ciph.c
ssl/ssl_conf.c
ssl/ssl_lib.c
ssl/ssl_sess.c
ssl/t1_enc.c
ssl/t1_ext.c
ssl/t1_lib.c
test/dhtest.c
test/ecdhtest.c
test/ecdsatest.c
test/evp_extra_test.c
test/evp_test.c
test/ssltest.c

index d68594ab27187e2e4df876d149800f0ed456164d..46cc5a05e71287474ba68440d12352400ab98b3e 100644 (file)
@@ -2165,9 +2165,7 @@ void jpake_client_auth(BIO *out, BIO *conn, const char *secret)
 
     BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
 
-    if (psk_key)
-        OPENSSL_free(psk_key);
-
+    OPENSSL_free(psk_key);
     psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
 
     BIO_pop(bconn);
@@ -2197,9 +2195,7 @@ void jpake_server_auth(BIO *out, BIO *conn, const char *secret)
 
     BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
 
-    if (psk_key)
-        OPENSSL_free(psk_key);
-
+    OPENSSL_free(psk_key);
     psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
 
     BIO_pop(bconn);
index 7e1dfb7327851d3e1650e1679e1400abd3440578..01a50f4e5d65f545c272598ba09a0c1e928387d3 100644 (file)
@@ -321,11 +321,9 @@ int asn1parse_main(int argc, char **argv)
         ERR_print_errors(bio_err);
     if (buf != NULL)
         BUF_MEM_free(buf);
-    if (name != NULL)
-        OPENSSL_free(name);
-    if (header != NULL)
-        OPENSSL_free(header);
-    if (strictpem && str != NULL)
+    OPENSSL_free(name);
+    OPENSSL_free(header);
+    if (strictpem)
         OPENSSL_free(str);
     ASN1_TYPE_free(at);
     if (osk != NULL)
index b703b425ae7934aa0e75d9b49f9881a057d072ec..ad6b000160189c17a165095012557a3c03ddeb91 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2271,8 +2271,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
     ok = 1;
  end:
     for (i = 0; i < DB_NUMBER; i++) {
-        if (row[i] != NULL)
-            OPENSSL_free(row[i]);
+        OPENSSL_free(row[i]);
     }
     return (ok);
 }
@@ -2339,8 +2338,7 @@ static int get_certificate_status(const char *serial, CA_DB *db)
     }
  end:
     for (i = 0; i < DB_NUMBER; i++) {
-        if (row[i] != NULL)
-            OPENSSL_free(row[i]);
+        OPENSSL_free(row[i]);
     }
     return (ok);
 }
@@ -2564,8 +2562,7 @@ int make_revoked(X509_REVOKED *rev, const char *str)
 
  end:
 
-    if (tmp)
-        OPENSSL_free(tmp);
+    OPENSSL_free(tmp);
     ASN1_OBJECT_free(hold);
     ASN1_GENERALIZEDTIME_free(comp_time);
     ASN1_ENUMERATED_free(rtmp);
@@ -2719,8 +2716,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
 
  end:
 
-    if (tmp)
-        OPENSSL_free(tmp);
+    OPENSSL_free(tmp);
     ASN1_GENERALIZEDTIME_free(comp_time);
 
     return ret;
index 907b108fc5eaa83292cf8e2c3180d2fc569b8b84..25e3ad62fd2eef205368b794fcc53a9cab58ff89 100644 (file)
@@ -1121,12 +1121,9 @@ int cms_main(int argc, char **argv)
         sk_OPENSSL_STRING_free(sksigners);
     if (skkeys)
         sk_OPENSSL_STRING_free(skkeys);
-    if (secret_key)
-        OPENSSL_free(secret_key);
-    if (secret_keyid)
-        OPENSSL_free(secret_keyid);
-    if (pwri_tmp)
-        OPENSSL_free(pwri_tmp);
+    OPENSSL_free(secret_key);
+    OPENSSL_free(secret_keyid);
+    OPENSSL_free(pwri_tmp);
     ASN1_OBJECT_free(econtent_type);
     if (rr)
         CMS_ReceiptRequest_free(rr);
@@ -1152,8 +1149,7 @@ int cms_main(int argc, char **argv)
     BIO_free(in);
     BIO_free(indata);
     BIO_free_all(out);
-    if (passin)
-        OPENSSL_free(passin);
+    OPENSSL_free(passin);
     return (ret);
 }
 
index 69211d34aca1bf16e9075d7c49eef699bd2c6145..a679cb9fe8ecc6f549fa3bff1d6a9cc2283b30fa 100644 (file)
@@ -451,8 +451,7 @@ int dgst_main(int argc, char **argv)
         sk_OPENSSL_STRING_free(sigopts);
     if (macopts)
         sk_OPENSSL_STRING_free(macopts);
-    if (sigbuf)
-        OPENSSL_free(sigbuf);
+    OPENSSL_free(sigbuf);
     BIO_free(bmd);
     return (ret);
 }
index c23ed5dac81edae0f12646098b23d8695744c13e..d864c75022dedafb7823f7c918f7708110b812cc 100644 (file)
@@ -275,10 +275,8 @@ int dsa_main(int argc, char **argv)
  end:
     BIO_free_all(out);
     DSA_free(dsa);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_DSA */
index 471de474e447948d63f47e16c64d1ca8c6dc756b..c56150c6895b66a2d03a9c5c245587496fb32427 100644 (file)
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -271,10 +271,8 @@ int ec_main(int argc, char **argv)
     BIO_free(in);
     BIO_free_all(out);
     EC_KEY_free(eckey);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_EC */
index 082df260ab2837bb8dfa0024e81399ca8e2e5b11..dd0e8f5c61f0075af7908d3d7b599b7bed0ea0a9 100644 (file)
@@ -489,8 +489,7 @@ int ecparam_main(int argc, char **argv)
     BN_free(ec_gen);
     BN_free(ec_order);
     BN_free(ec_cofactor);
-    if (buffer)
-        OPENSSL_free(buffer);
+    OPENSSL_free(buffer);
     BIO_free(in);
     BIO_free_all(out);
     EC_GROUP_free(group);
index 83067b830a84c01eb22d09bad3dd9e275a9cffb8..8b892cfea9ef4f3066409723238216b11ad0ab2d 100644 (file)
@@ -564,10 +564,8 @@ int enc_main(int argc, char **argv)
     }
  end:
     ERR_print_errors(bio_err);
-    if (strbuf != NULL)
-        OPENSSL_free(strbuf);
-    if (buff != NULL)
-        OPENSSL_free(buff);
+    OPENSSL_free(strbuf);
+    OPENSSL_free(buff);
     BIO_free(in);
     BIO_free_all(out);
     BIO_free(benc);
@@ -575,8 +573,7 @@ int enc_main(int argc, char **argv)
 #ifdef ZLIB
     BIO_free(bzl);
 #endif
-    if (pass)
-        OPENSSL_free(pass);
+    OPENSSL_free(pass);
     return (ret);
 }
 
index 448802bc611ea90b7e12a31b3b61603c0ede2d57..c7c0aafd75df5c1cb0db4220c814309e9f41edf1 100644 (file)
@@ -252,10 +252,8 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
         }
         OPENSSL_free(name);
         name = NULL;
-        if (desc) {
-            OPENSSL_free(desc);
-            desc = NULL;
-        }
+        OPENSSL_free(desc);
+        desc = NULL;
         /* Move to the next command */
         num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE, num, NULL, NULL);
     } while (num > 0);
@@ -265,10 +263,8 @@ static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
  err:
     if (cmds)
         sk_OPENSSL_STRING_pop_free(cmds, identity);
-    if (name)
-        OPENSSL_free(name);
-    if (desc)
-        OPENSSL_free(desc);
+    OPENSSL_free(name);
+    OPENSSL_free(desc);
     return ret;
 }
 
index 21988a06522dce5c78de4771e04a6bd6b3679189..75bd802e6634abe74fa860d298ad2b293b0dee50 100644 (file)
@@ -182,8 +182,7 @@ int gendsa_main(int argc, char **argv)
     BIO_free(in);
     BIO_free_all(out);
     DSA_free(dsa);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passout);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_DSA */
index ae68e7a4427110d0c9b92e2553c3f0728ab88cb9..de14bd3810fe88aefced724540327286253c505c 100644 (file)
@@ -235,8 +235,7 @@ int genpkey_main(int argc, char **argv)
     EVP_PKEY_CTX_free(ctx);
     BIO_free_all(out);
     BIO_free(in);
-    if (pass)
-        OPENSSL_free(pass);
+    OPENSSL_free(pass);
 
     return ret;
 }
index a3c00d871e61a2ee1da2747bee822903b1263bae..a5ab658f96d5b9a8cf81deab4c7b225e07f5e773 100644 (file)
@@ -218,8 +218,7 @@ int genrsa_main(int argc, char **argv)
     BN_GENCB_free(cb);
     RSA_free(rsa);
     BIO_free_all(out);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passout);
     if (ret != 0)
         ERR_print_errors(bio_err);
     return (ret);
index 20dc1ae4cc7115a84a4c7cc962cf4e5491742f00..d4ea0196508397eead4ddf45594762eb4e5bd9ed 100644 (file)
@@ -271,12 +271,9 @@ int ocsp_main(int argc, char **argv)
             req_timeout = atoi(opt_arg());
             break;
         case OPT_URL:
-            if (thost)
-                OPENSSL_free(thost);
-            if (tport)
-                OPENSSL_free(tport);
-            if (tpath)
-                OPENSSL_free(tpath);
+            OPENSSL_free(thost);
+            OPENSSL_free(tport);
+            OPENSSL_free(tpath);
             if (!OCSP_parse_url(opt_arg(), &host, &port, &path, &use_ssl)) {
                 BIO_printf(bio_err, "%s Error parsing URL\n", prog);
                 goto end;
@@ -753,13 +750,9 @@ int ocsp_main(int argc, char **argv)
     sk_X509_pop_free(sign_other, X509_free);
     sk_X509_pop_free(verify_other, X509_free);
     sk_CONF_VALUE_pop_free(headers, X509V3_conf_free);
-
-    if (thost)
-        OPENSSL_free(thost);
-    if (tport)
-        OPENSSL_free(tport);
-    if (tpath)
-        OPENSSL_free(tpath);
+    OPENSSL_free(thost);
+    OPENSSL_free(tport);
+    OPENSSL_free(tpath);
 
     return (ret);
 }
index f6013f70acc188ee4e7b6b04c6b61e22b2721caf..c6b048a90df3d593bb172c4beda8c30913ae1a93 100644 (file)
@@ -509,18 +509,15 @@ int main(int argc, char *argv[])
     }
     ret = 1;
  end:
-    if (copied_argv)
-        OPENSSL_free(copied_argv);
-    if (to_free)
-        OPENSSL_free(to_free);
+    OPENSSL_free(copied_argv);
+    OPENSSL_free(to_free);
     if (config != NULL) {
         NCONF_free(config);
         config = NULL;
     }
     if (prog != NULL)
         lh_FUNCTION_free(prog);
-    if (arg.argv != NULL)
-        OPENSSL_free(arg.argv);
+    OPENSSL_free(arg.argv);
 
     BIO_free(bio_in);
     BIO_free_all(bio_out);
index c529792eed9f69b9c4b2eb6952c5d7e4fd0020b5..8dd85428706514b4110dcfbc6919c999175bf75c 100644 (file)
@@ -284,10 +284,8 @@ int passwd_main(int argc, char **argv)
 
  end:
     ERR_print_errors(bio_err);
-    if (salt_malloc)
-        OPENSSL_free(salt_malloc);
-    if (passwd_malloc)
-        OPENSSL_free(passwd_malloc);
+    OPENSSL_free(salt_malloc);
+    OPENSSL_free(passwd_malloc);
     BIO_free(in);
     return (ret);
 }
index b4b37305bb5eea4731a0333bf7694590c82bfa2a..4c62392e0b14264421699a9bf0e33c149dc259f1 100644 (file)
@@ -556,10 +556,8 @@ int pkcs12_main(int argc, char **argv)
     BIO_free_all(out);
     if (canames)
         sk_OPENSSL_STRING_free(canames);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     return (ret);
 }
 
index 105c1cb61c4829cc6114d5f011f2d37b35005a7b..07ebf3b86ff82fd4f512660b6e1f036b3e0248d3 100644 (file)
@@ -343,10 +343,8 @@ int pkcs8_main(int argc, char **argv)
     EVP_PKEY_free(pkey);
     BIO_free_all(out);
     BIO_free(in);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
 
     return ret;
 }
index 716d6d01e80df2bdbc627a9608c8fa0465556a8f..f0930a74f0161598b2044601077b5566004927da 100644 (file)
@@ -208,10 +208,8 @@ int pkey_main(int argc, char **argv)
     EVP_PKEY_free(pkey);
     BIO_free_all(out);
     BIO_free(in);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
 
     return ret;
 }
index 3afe0eb033f49f0a54923b5b98d8fbea2ecedf6e..87e49501ab372afa3438c37402c21dc71c10fe18 100644 (file)
@@ -322,12 +322,9 @@ int pkeyutl_main(int argc, char **argv)
     EVP_PKEY_CTX_free(ctx);
     BIO_free(in);
     BIO_free_all(out);
-    if (buf_in)
-        OPENSSL_free(buf_in);
-    if (buf_out)
-        OPENSSL_free(buf_out);
-    if (sig)
-        OPENSSL_free(sig);
+    OPENSSL_free(buf_in);
+    OPENSSL_free(buf_out);
+    OPENSSL_free(sig);
     return ret;
 }
 
@@ -413,10 +410,7 @@ static EVP_PKEY_CTX *init_ctx(int *pkeysize,
     }
 
  end:
-
-    if (passin)
-        OPENSSL_free(passin);
-
+    OPENSSL_free(passin);
     return ctx;
 
 }
index 0502a64abf20561359b62deda2151c643eb3f544..4ff3b246feca424b4193b709244cc4cbeb4f9e69 100644 (file)
@@ -886,15 +886,12 @@ int req_main(int argc, char **argv)
     if (gen_eng)
         ENGINE_free(gen_eng);
 #endif
-    if (keyalgstr)
-        OPENSSL_free(keyalgstr);
+    OPENSSL_free(keyalgstr);
     X509_REQ_free(req);
     X509_free(x509ss);
     ASN1_INTEGER_free(serial);
-    if (passargin && passin)
-        OPENSSL_free(passin);
-    if (passargout && passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     OBJ_cleanup();
     return (ret);
 }
index 0a8e198d8ed1ef0fda8cd3498e8a409fd0965041..858699bc18cd5c542d6180cb0d128d9d29c007c7 100644 (file)
@@ -388,10 +388,8 @@ int rsa_main(int argc, char **argv)
  end:
     BIO_free_all(out);
     RSA_free(rsa);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_RSA */
index f138293a18b8b864017f69453bbc5f09ae806674..0ef61050cb818c839f94d19057bb5289127fd636 100644 (file)
@@ -315,12 +315,9 @@ int rsautl_main(int argc, char **argv)
     RSA_free(rsa);
     BIO_free(in);
     BIO_free_all(out);
-    if (rsa_in)
-        OPENSSL_free(rsa_in);
-    if (rsa_out)
-        OPENSSL_free(rsa_out);
-    if (passin)
-        OPENSSL_free(passin);
+    OPENSSL_free(rsa_in);
+    OPENSSL_free(rsa_out);
+    OPENSSL_free(passin);
     return ret;
 }
 
index 8d8340d311baa1ced6af4be7683b8ab7bba7249a..a24d2f3b9dd003323bc742fb0007323752c36e8d 100644 (file)
@@ -1985,24 +1985,18 @@ int s_client_main(int argc, char **argv)
         SSL_free(con);
     }
 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
-    if (next_proto.data)
-        OPENSSL_free(next_proto.data);
+    OPENSSL_free(next_proto.data);
 #endif
     SSL_CTX_free(ctx);
     X509_free(cert);
     sk_X509_CRL_pop_free(crls, X509_CRL_free);
     EVP_PKEY_free(key);
     sk_X509_pop_free(chain, X509_free);
-    if (pass)
-        OPENSSL_free(pass);
+    OPENSSL_free(pass);
     X509_VERIFY_PARAM_free(vpm);
     ssl_excert_free(exc);
     sk_OPENSSL_STRING_free(ssl_args);
     SSL_CONF_CTX_free(cctx);
-#ifndef OPENSSL_NO_JPAKE
-    if (jpake_secret && psk_key)
-        OPENSSL_free(psk_key);
-#endif
     OPENSSL_clear_free(cbuf, BUFSIZZ);
     OPENSSL_clear_free(sbuf, BUFSIZZ);
     OPENSSL_clear_free(mbuf, BUFSIZZ);
index a616b64a1183dfc56a0bbf27c94b6e0ac066461b..5fb275d0d8d2040af431b922cd97e4e10b2eb6c3 100644 (file)
@@ -1956,10 +1956,6 @@ int s_server_main(int argc, char *argv[])
     ssl_excert_free(exc);
     sk_OPENSSL_STRING_free(ssl_args);
     SSL_CONF_CTX_free(cctx);
-#ifndef OPENSSL_NO_JPAKE
-    if (jpake_secret && psk_key)
-        OPENSSL_free(psk_key);
-#endif
     BIO_free(bio_s_out);
     bio_s_out = NULL;
     BIO_free(bio_s_msg);
@@ -2931,8 +2927,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
  err:
     if (ret >= 0)
         BIO_printf(bio_s_out, "ACCEPT\n");
-    if (buf != NULL)
-        OPENSSL_free(buf);
+    OPENSSL_free(buf);
     BIO_free_all(io);
     return (ret);
 }
@@ -3065,8 +3060,7 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
 
  err:
 
-    if (buf != NULL)
-        OPENSSL_free(buf);
+    OPENSSL_free(buf);
     BIO_free_all(io);
     return (ret);
 }
index caa5b61053f24eda45f186933004af7a348ceee3..29240e846277f640212c504faf659b144fa1c2db 100644 (file)
@@ -354,8 +354,7 @@ int do_server(int port, int type, int *ret,
         } else
             sock = accept_socket;
         i = (*cb) (name, sock, type, context);
-        if (name != NULL)
-            OPENSSL_free(name);
+        OPENSSL_free(name);
         if (type == SOCK_STREAM)
             SHUTDOWN2(sock);
         if (naccept != -1)
index 0fda865565db9b8388eccfafdf34c188283153f3..8b8520b37c164ec2874c769c47bc744edd65e4d7 100644 (file)
@@ -664,8 +664,7 @@ int smime_main(int argc, char **argv)
     BIO_free(in);
     BIO_free(indata);
     BIO_free_all(out);
-    if (passin)
-        OPENSSL_free(passin);
+    OPENSSL_free(passin);
     return (ret);
 }
 
index 08ab9c5fa6deee921846aa0e914ea9fbc3d6cbb3..a5bd2658b9f83b173dfc2d0a08e91b9baed8874a 100644 (file)
@@ -2529,8 +2529,6 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher)
         fprintf(stdout, "\n");
     }
 
-    if (inp)
-        OPENSSL_free(inp);
-    if (out)
-        OPENSSL_free(out);
+    OPENSSL_free(inp);
+    OPENSSL_free(out);
 }
index 7ceff9feca1427e5984c771e4124050864fe697e..abae0e14acd01abe00a09bcfbcfb1bd1fec85931 100644 (file)
@@ -240,7 +240,6 @@ int spkac_main(int argc, char **argv)
     BIO_free(in);
     BIO_free_all(out);
     EVP_PKEY_free(pkey);
-    if (passin)
-        OPENSSL_free(passin);
+    OPENSSL_free(passin);
     return (ret);
 }
index b984c14c97ab3088e4fec6d1897011a987bacd40..960ca822f75ae0a0b17d5f54cb4d1bf4c34f94e5 100644 (file)
@@ -384,10 +384,8 @@ int srp_main(int argc, char **argv)
                            errorline, configfile);
             goto end;
         }
-        if (tofree) {
-            OPENSSL_free(tofree);
-            tofree = NULL;
-        }
+        OPENSSL_free(tofree);
+        tofree = NULL;
 
         /* Lets get the config section we are using */
         if (section == NULL) {
@@ -519,26 +517,16 @@ int srp_main(int argc, char **argv)
                 row[DB_srpgN] = BUF_strdup(gNid);
 
                 if (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype]
-                    || !row[DB_srpverifier] || !row[DB_srpsalt] || (userinfo
-                                                                    &&
-                                                                    (!(row
-                                                                       [DB_srpinfo]
-                                                                       =
-                                                                       BUF_strdup
-                                                                       (userinfo))))
+                    || !row[DB_srpverifier] || !row[DB_srpsalt]
+                    || (userinfo &&
+                         (!(row [DB_srpinfo] = BUF_strdup (userinfo))))
                     || !update_index(db, row)) {
-                    if (row[DB_srpid])
-                        OPENSSL_free(row[DB_srpid]);
-                    if (row[DB_srpgN])
-                        OPENSSL_free(row[DB_srpgN]);
-                    if (row[DB_srpinfo])
-                        OPENSSL_free(row[DB_srpinfo]);
-                    if (row[DB_srptype])
-                        OPENSSL_free(row[DB_srptype]);
-                    if (row[DB_srpverifier])
-                        OPENSSL_free(row[DB_srpverifier]);
-                    if (row[DB_srpsalt])
-                        OPENSSL_free(row[DB_srpsalt]);
+                    OPENSSL_free(row[DB_srpid]);
+                    OPENSSL_free(row[DB_srpgN]);
+                    OPENSSL_free(row[DB_srpinfo]);
+                    OPENSSL_free(row[DB_srptype]);
+                    OPENSSL_free(row[DB_srpverifier]);
+                    OPENSSL_free(row[DB_srpsalt]);
                     goto end;
                 }
                 doupdatedb = 1;
@@ -676,8 +664,7 @@ int srp_main(int argc, char **argv)
 
     if (verbose)
         BIO_printf(bio_err, "SRP terminating with code %d.\n", ret);
-    if (tofree)
-        OPENSSL_free(tofree);
+    OPENSSL_free(tofree);
     if (ret)
         ERR_print_errors(bio_err);
     if (randfile)
index 5418cce8cf80c70802d20844554b0a6162f0fe53..31ae38aeaaa665f3eff72445f30fbc3d81a51b92 100644 (file)
@@ -955,8 +955,7 @@ int x509_main(int argc, char **argv)
     ASN1_INTEGER_free(sno);
     sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
     sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
-    if (passin)
-        OPENSSL_free(passin);
+    OPENSSL_free(passin);
     return (ret);
 }
 
@@ -996,8 +995,7 @@ static ASN1_INTEGER *x509_load_serial(char *CAfile, char *serialfile,
         goto end;
 
  end:
-    if (buf)
-        OPENSSL_free(buf);
+    OPENSSL_free(buf);
     BN_free(serial);
     return bs;
 }
index ba243f1a5f5c47b1dc09fff8632fa7c7a7cc0186..60b6e6d40385e4c17399161854c75e7fc7e071cb 100644 (file)
@@ -168,8 +168,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
         s = NULL;
 
     ret->length = (int)len;
-    if (ret->data != NULL)
-        OPENSSL_free(ret->data);
+    OPENSSL_free(ret->data);
     ret->data = s;
     ret->type = V_ASN1_BIT_STRING;
     if (a != NULL)
index 54d6542cbe2568ee2bc7fea3184d3b4337773df8..4abd80c12250f8aef4c87010157c2b977d9ccc39 100644 (file)
@@ -75,8 +75,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
 
     a->type = V_ASN1_ENUMERATED;
     if (a->length < (int)(sizeof(long) + 1)) {
-        if (a->data != NULL)
-            OPENSSL_free(a->data);
+        OPENSSL_free(a->data);
         if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
             memset((char *)a->data, 0, sizeof(long) + 1);
     }
index 0e9149a3ca38b70bb68b31ea8d68b0a88e77298f..324496e30cae811c4697eaa03c283a50347d07a3 100644 (file)
@@ -243,8 +243,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
             ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE);
             return (NULL);
         }
-        if (s->data != NULL)
-            OPENSSL_free(s->data);
+        OPENSSL_free(s->data);
         s->data = (unsigned char *)p;
     }
 
index b5246a65c39e1ecd38cfebb2d15fa32b4ac83a6b..68a312b97a1de4edfe1bf8881be93c4a20a92815 100644 (file)
@@ -258,8 +258,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
         memcpy(s, p, (int)len);
     }
 
-    if (ret->data != NULL)
-        OPENSSL_free(ret->data);
+    OPENSSL_free(ret->data);
     ret->data = s;
     ret->length = (int)len;
     if (a != NULL)
@@ -327,8 +326,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
         p += len;
     }
 
-    if (ret->data != NULL)
-        OPENSSL_free(ret->data);
+    OPENSSL_free(ret->data);
     ret->data = s;
     ret->length = (int)len;
     if (a != NULL)
@@ -349,8 +347,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
     unsigned char buf[sizeof(long) + 1];
 
     if (a->length < (int)(sizeof(long) + 1)) {
-        if (a->data != NULL)
-            OPENSSL_free(a->data);
+        OPENSSL_free(a->data);
         if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
             memset((char *)a->data, 0, sizeof(long) + 1);
     }
index 6935efe09fb5080d39f8f3177e5160d897f7d31f..2ff496b4fd3573c9c50cc60258b2251f4758750a 100644 (file)
@@ -190,11 +190,9 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
     if (*out) {
         free_out = 0;
         dest = *out;
-        if (dest->data) {
-            dest->length = 0;
-            OPENSSL_free(dest->data);
-            dest->data = NULL;
-        }
+        OPENSSL_free(dest->data);
+        dest->data = NULL;
+        dest->length = 0;
         dest->type = str_type;
     } else {
         free_out = 1;
index 1e76122192bdcdea031418e6ccb1f76808614570..809e9a4112d5dabaa2c3113fc8fa076b04da7c7d 100644 (file)
@@ -313,8 +313,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
     /* once detached we can change it */
     if ((data == NULL) || (ret->length < length)) {
         ret->length = 0;
-        if (data != NULL)
-            OPENSSL_free(data);
+        OPENSSL_free(data);
         data = OPENSSL_malloc(length);
         if (data == NULL) {
             i = ERR_R_MALLOC_FAILURE;
@@ -368,16 +367,13 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
 #ifndef CONST_STRICT            /* disable purely for compile-time strict
                                  * const checking. Doing this on a "real"
                                  * compile will cause memory leaks */
-        if (a->sn != NULL)
-            OPENSSL_free((void *)a->sn);
-        if (a->ln != NULL)
-            OPENSSL_free((void *)a->ln);
+        OPENSSL_free((void*)a->sn);
+        OPENSSL_free((void*)a->ln);
 #endif
         a->sn = a->ln = NULL;
     }
     if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {
-        if (a->data != NULL)
-            OPENSSL_free((void *)a->data);
+        OPENSSL_free((void*)a->data);
         a->data = NULL;
         a->length = 0;
     }
index fb7536d84ef141f73686dc32f845a8ee0905147f..e189958174cd0dd349076cea580917fb62fcf1b2 100644 (file)
@@ -190,8 +190,7 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
         ASN1err(ASN1_F_ASN1_SIGN, ERR_R_EVP_LIB);
         goto err;
     }
-    if (signature->data != NULL)
-        OPENSSL_free(signature->data);
+    OPENSSL_free(signature->data);
     signature->data = buf_out;
     buf_out = NULL;
     signature->length = outl;
@@ -300,8 +299,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
         ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
         goto err;
     }
-    if (signature->data != NULL)
-        OPENSSL_free(signature->data);
+    OPENSSL_free(signature->data);
     signature->data = buf_out;
     buf_out = NULL;
     signature->length = outl;
index 0e2f1b0c40b506c2331536ac15f8ba9ef5b5139e..5fd1a6a3c49c8aa60a2940d60b82a755a86d675b 100644 (file)
@@ -218,8 +218,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
             ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE);
             goto err;
         }
-        if (s->data != NULL)
-            OPENSSL_free(s->data);
+        OPENSSL_free(s->data);
         s->data = (unsigned char *)p;
     }
 
index 5c7d6bb207adadbded5595a9c0ba61f8104dc246..718aa521c5fbd669b369e5799f7f467131f60dfe 100644 (file)
@@ -384,10 +384,8 @@ void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
 {
     if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) {
-        if (ameth->pem_str)
-            OPENSSL_free(ameth->pem_str);
-        if (ameth->info)
-            OPENSSL_free(ameth->info);
+        OPENSSL_free(ameth->pem_str);
+        OPENSSL_free(ameth->info);
         OPENSSL_free(ameth);
     }
 }
index 3e066bc3e83137b681d85046d79befe35b2aece1..6756c67a4792c7ec00e8a0876a2f7bdd91023e0d 100644 (file)
@@ -280,10 +280,8 @@ static ASN1_TYPE *generate_v3(char *str, X509V3_CTX *cnf, int depth,
     ret = d2i_ASN1_TYPE(NULL, &cp, len);
 
  err:
-    if (orig_der)
-        OPENSSL_free(orig_der);
-    if (new_der)
-        OPENSSL_free(new_der);
+    OPENSSL_free(orig_der);
+    OPENSSL_free(new_der);
 
     return ret;
 
@@ -510,8 +508,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
 
  bad:
 
-    if (der)
-        OPENSSL_free(der);
+    OPENSSL_free(der);
 
     sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
     if (sect)
index a892d7f063141539e2c9ef3387be45e238232c3d..e1e509b3ec15ca9a5a1e6c2b54fcfd3844068add 100644 (file)
@@ -335,8 +335,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
 
 void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
 {
-    if (str->data)
-        OPENSSL_free(str->data);
+    OPENSSL_free(str->data);
     str->data = data;
     str->length = len;
 }
@@ -366,7 +365,7 @@ void ASN1_STRING_free(ASN1_STRING *a)
 {
     if (a == NULL)
         return;
-    if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
+    if (!(a->flags & ASN1_STRING_FLAG_NDEF))
         OPENSSL_free(a->data);
     OPENSSL_free(a);
 }
index 9b397aeaa03d17e392353c0a678549299d7ac711..e8411a82ad1547736a13e1dfa02825514ea45e63 100644 (file)
@@ -854,12 +854,9 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
     return mhdr;
 
  err:
-    if (tmpname != NULL)
-        OPENSSL_free(tmpname);
-    if (tmpval != NULL)
-        OPENSSL_free(tmpval);
-    if (mhdr != NULL)
-        OPENSSL_free(mhdr);
+    OPENSSL_free(tmpname);
+    OPENSSL_free(tmpval);
+    OPENSSL_free(mhdr);
     return NULL;
 }
 
@@ -895,12 +892,9 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
         goto err;
     return 1;
  err:
-    if (tmpname != NULL)
-        OPENSSL_free(tmpname);
-    if (tmpval != NULL)
-        OPENSSL_free(tmpval);
-    if (mparam != NULL)
-        OPENSSL_free(mparam);
+    OPENSSL_free(tmpname);
+    OPENSSL_free(tmpval);
+    OPENSSL_free(mparam);
     return 0;
 }
 
@@ -947,10 +941,8 @@ static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
 
 static void mime_hdr_free(MIME_HEADER *hdr)
 {
-    if (hdr->name)
-        OPENSSL_free(hdr->name);
-    if (hdr->value)
-        OPENSSL_free(hdr->value);
+    OPENSSL_free(hdr->name);
+    OPENSSL_free(hdr->value);
     if (hdr->params)
         sk_MIME_PARAM_pop_free(hdr->params, mime_param_free);
     OPENSSL_free(hdr);
@@ -958,10 +950,8 @@ static void mime_hdr_free(MIME_HEADER *hdr)
 
 static void mime_param_free(MIME_PARAM *param)
 {
-    if (param->param_name)
-        OPENSSL_free(param->param_name);
-    if (param->param_value)
-        OPENSSL_free(param->param_value);
+    OPENSSL_free(param->param_name);
+    OPENSSL_free(param->param_value);
     OPENSSL_free(param);
 }
 
index 8d0f0b091f188d22681c535c6dcaafda1e139c8a..e358a8676f75ef37f7b4c4f3d6895b238fbc3fa2 100644 (file)
@@ -77,10 +77,8 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
     } else
         octmp = *oct;
 
-    if (octmp->data) {
-        OPENSSL_free(octmp->data);
-        octmp->data = NULL;
-    }
+    OPENSSL_free(octmp->data);
+    octmp->data = NULL;
 
     if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
         ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR);
index d4be23c1901c96d84bb60b5350149e84e7fc4d5f..ba390693742a0b00a6df88dd5466b9895dfe6217 100644 (file)
@@ -183,8 +183,7 @@ static int asn1_bio_free(BIO *b)
 
     if (ctx == NULL)
         return 0;
-    if (ctx->buf)
-        OPENSSL_free(ctx->buf);
+    OPENSSL_free(ctx->buf);
     OPENSSL_free(ctx);
     b->init = 0;
     b->ptr = NULL;
index 99ab5f66e15185b4b13127f6f2308e501b2ac333..de517f22e40d5ea12f5f44dac326a804ebe78b86 100644 (file)
@@ -143,8 +143,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
 
  err:
     BIO_free(asn_bio);
-    if (ndef_aux)
-        OPENSSL_free(ndef_aux);
+    OPENSSL_free(ndef_aux);
     return NULL;
 }
 
@@ -186,8 +185,7 @@ static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen,
 
     ndef_aux = *(NDEF_SUPPORT **)parg;
 
-    if (ndef_aux->derbuf)
-        OPENSSL_free(ndef_aux->derbuf);
+    OPENSSL_free(ndef_aux->derbuf);
 
     ndef_aux->derbuf = NULL;
     *pbuf = NULL;
index 2ec99a51a3417076c8812d962afae1b876805640..338a02e291c3342f7dadb0c48c17b747a80da4b5 100644 (file)
@@ -154,8 +154,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
             sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
             if (sp == NULL) {
                 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
-                if (s != NULL)
-                    OPENSSL_free(s);
+                OPENSSL_free(s);
                 goto err;
             }
             s = sp;
index f74252c45a4247a7a6ba228c7a1867d36fe584cb..5a2d18b582177f75ff8aedb263f3485439aad073 100644 (file)
@@ -168,8 +168,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
             sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
             if (sp == NULL) {
                 ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
-                if (s != NULL)
-                    OPENSSL_free(s);
+                OPENSSL_free(s);
                 goto err;
             }
             s = sp;
index 53f8cf3a83a8cd4a36b5782dc107d446d89f0ae1..e9dcee8e86f5bd455e7f81ceac30a1b8d3365b64 100644 (file)
@@ -160,8 +160,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
             sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
             if (sp == NULL) {
                 ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
-                if (s != NULL)
-                    OPENSSL_free(s);
+                OPENSSL_free(s);
                 goto err;
             }
             s = sp;
index da73b6dfc8ba8b47b8b51ba42df268256aea1a81..c32f28efee35c5cefe6ff047196e2a20d7cd8f07 100644 (file)
@@ -249,8 +249,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
     }
     ret = 1;
  err:
-    if (m != NULL)
-        OPENSSL_free(m);
+    OPENSSL_free(m);
     return (ret);
 }
 
@@ -299,8 +298,7 @@ int X509_ocspid_print(BIO *bp, X509 *x)
 
     return (1);
  err:
-    if (der != NULL)
-        OPENSSL_free(der);
+    OPENSSL_free(der);
     return (0);
 }
 
index ef19fcdfaea0edeaefd3fe393ad3e3f005e47132..c5caff7dddceef28b6675a564458a6af3c1cc7e5 100644 (file)
@@ -765,7 +765,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
     *in = p;
     ret = 1;
  err:
-    if (free_cont && buf.data)
+    if (free_cont)
         OPENSSL_free(buf.data);
     return ret;
 }
@@ -882,8 +882,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
         }
         /* If we've already allocated a buffer use it */
         if (*free_cont) {
-            if (stmp->data)
-                OPENSSL_free(stmp->data);
+            OPENSSL_free(stmp->data);
             stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
             stmp->length = len;
             *free_cont = 0;
index 10974eb7f4b65ec76ac48508f44157270aabe44d..76d584b2baa2f4974372c9e9353c5c2433992c24 100644 (file)
@@ -100,8 +100,7 @@ ASN1_PCTX *ASN1_PCTX_new(void)
 
 void ASN1_PCTX_free(ASN1_PCTX *p)
 {
-    if (p)
-        OPENSSL_free(p);
+    OPENSSL_free(p);
 }
 
 unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
index 830540550e22dc7d5d9b68d051635d7f93d41de7..cedea9cb78e378cb135472f6a7745bf61ad731c9 100644 (file)
@@ -86,8 +86,7 @@ ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx))
 
 void ASN1_SCTX_free(ASN1_SCTX *p)
 {
-    if (p)
-        OPENSSL_free(p);
+    OPENSSL_free(p);
 }
 
 const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p)
index 17318ea587744d24594fed1311d913e697507985..76e96051bf476a4a570d59ed21d3349232bdee60 100644 (file)
@@ -154,8 +154,7 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
     ASN1_ENCODING *enc;
     enc = asn1_get_enc_ptr(pval, it);
     if (enc) {
-        if (enc->enc)
-            OPENSSL_free(enc->enc);
+        OPENSSL_free(enc->enc);
         enc->enc = NULL;
         enc->len = 0;
         enc->modified = 1;
@@ -170,8 +169,7 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
     if (!enc)
         return 1;
 
-    if (enc->enc)
-        OPENSSL_free(enc->enc);
+    OPENSSL_free(enc->enc);
     enc->enc = OPENSSL_malloc(inlen);
     if (!enc->enc)
         return 0;
index 4783fc48a95c961254363c85521094a61ae0e130..5b927efc67e8206cd35a0c7f2261aed4949bd135 100644 (file)
@@ -106,7 +106,6 @@ void X509_INFO_free(X509_INFO *x)
     X509_free(x->x509);
     X509_CRL_free(x->crl);
     X509_PKEY_free(x->x_pkey);
-    if (x->enc_data != NULL)
-        OPENSSL_free(x->enc_data);
+    OPENSSL_free(x->enc_data);
     OPENSSL_free(x);
 }
index fc5de8a96f7926a96d9fada28610f18fe9674721..59e002bd457e18b57a6147fe11ba83ca4efff854 100644 (file)
@@ -113,7 +113,7 @@ void X509_PKEY_free(X509_PKEY *x)
     X509_ALGOR_free(x->enc_algor);
     ASN1_OCTET_STRING_free(x->enc_pkey);
     EVP_PKEY_free(x->dec_pkey);
-    if ((x->key_data != NULL) && (x->key_free))
+    if (x->key_free)
         OPENSSL_free(x->key_data);
     OPENSSL_free(x);
 }
index 158c24062e541ff2778ad5846b88b5de003e0679..2605f07013bf5d4368885164024b97a19d33c267 100644 (file)
@@ -340,8 +340,7 @@ int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
     if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval))
         return 0;
     if (penc) {
-        if (pub->public_key->data)
-            OPENSSL_free(pub->public_key->data);
+        OPENSSL_free(pub->public_key->data);
         pub->public_key->data = penc;
         pub->public_key->length = penclen;
         /* Set number of unused bits to zero */
index 08bb4bd33c12fa887f0e1b2819de132cb425b9e2..1b353af8445d468e84df311c0017293203ea3011 100644 (file)
@@ -103,8 +103,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
         break;
 
     case ASN1_OP_D2I_POST:
-        if (ret->name != NULL)
-            OPENSSL_free(ret->name);
+        OPENSSL_free(ret->name);
         ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0);
         break;
 
@@ -119,9 +118,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
         NAME_CONSTRAINTS_free(ret->nc);
         sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
         ASIdentifiers_free(ret->rfc3779_asid);
-
-        if (ret->name != NULL)
-            OPENSSL_free(ret->name);
+        OPENSSL_free(ret->name);
         break;
 
     }
index a4fded5ec2a8517a7f6e572d5e5baeeb368c23f1..39499de591096d4562f8be83aff6128a4340db06 100644 (file)
@@ -572,8 +572,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
     }
     ret = 1;
  err:
-    if (str != NULL)
-        OPENSSL_free(str);
+    OPENSSL_free(str);
     if ((ret == 0) && (s != INVALID_SOCKET)) {
         closesocket(s);
         s = INVALID_SOCKET;
index d82385a06c2e298052b5d5d12b6a6a1cc36334e1..53a120465a712da67290b76784038ac08287df78 100644 (file)
@@ -127,10 +127,8 @@ static int buffer_free(BIO *a)
     if (a == NULL)
         return (0);
     b = (BIO_F_BUFFER_CTX *)a->ptr;
-    if (b->ibuf != NULL)
-        OPENSSL_free(b->ibuf);
-    if (b->obuf != NULL)
-        OPENSSL_free(b->obuf);
+    OPENSSL_free(b->ibuf);
+    OPENSSL_free(b->obuf);
     OPENSSL_free(a->ptr);
     a->ptr = NULL;
     a->init = 0;
@@ -339,8 +337,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
             p1 = OPENSSL_malloc((int)num);
             if (p1 == NULL)
                 goto malloc_error;
-            if (ctx->ibuf != NULL)
-                OPENSSL_free(ctx->ibuf);
+            OPENSSL_free(ctx->ibuf);
             ctx->ibuf = p1;
         }
         ctx->ibuf_off = 0;
index ef12820b507ef0b1ed51636e7bdb0ede966bec92..d7906b419cfdb66e73f8dfe7812a912aa868699c 100644 (file)
@@ -128,8 +128,7 @@ static int linebuffer_free(BIO *a)
     if (a == NULL)
         return (0);
     b = (BIO_LINEBUFFER_CTX *)a->ptr;
-    if (b->obuf != NULL)
-        OPENSSL_free(b->obuf);
+    OPENSSL_free(b->obuf);
     OPENSSL_free(a->ptr);
     a->ptr = NULL;
     a->init = 0;
index df547a1027296c08524d9b56eccf3223fe948fc1..9b9c0c08b2d29c668b929b2953f56c2e515fc871 100644 (file)
@@ -116,8 +116,7 @@ static int nbiof_free(BIO *a)
 {
     if (a == NULL)
         return (0);
-    if (a->ptr != NULL)
-        OPENSSL_free(a->ptr);
+    OPENSSL_free(a->ptr);
     a->ptr = NULL;
     a->init = 0;
     a->flags = 0;
index d6f66789d84d9855de2d1d892cd3fbb1e6c11ae9..6793fe17accbc4a4887385f3e135758d9ab0cbbb 100644 (file)
@@ -151,10 +151,8 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a)
     if (a == NULL)
         return;
 
-    if (a->param_addr != NULL)
-        OPENSSL_free(a->param_addr);
-    if (a->addr != NULL)
-        OPENSSL_free(a->addr);
+    OPENSSL_free(a->param_addr);
+    OPENSSL_free(a->addr);
     BIO_free(a->bio_chain);
     OPENSSL_free(a);
 }
@@ -353,8 +351,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
         if (ptr != NULL) {
             if (num == 0) {
                 b->init = 1;
-                if (data->param_addr != NULL)
-                    OPENSSL_free(data->param_addr);
+                OPENSSL_free(data->param_addr);
                 data->param_addr = BUF_strdup(ptr);
             } else if (num == 1) {
                 data->accept_nbio = (ptr != NULL);
index c6bb3d68857a722c0506dfa105735ce1dec03e98..c9b8e7f1c64c1f182662f984e32d7bb92ef2f914 100644 (file)
@@ -170,10 +170,7 @@ static int bio_free(BIO *bio)
     if (b->peer)
         bio_destroy_pair(bio);
 
-    if (b->buf != NULL) {
-        OPENSSL_free(b->buf);
-    }
-
+    OPENSSL_free(b->buf);
     OPENSSL_free(b);
 
     return 1;
@@ -507,10 +504,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
             size_t new_size = num;
 
             if (b->size != new_size) {
-                if (b->buf) {
-                    OPENSSL_free(b->buf);
-                    b->buf = NULL;
-                }
+                OPENSSL_free(b->buf);
+                b->buf = NULL;
                 b->size = new_size;
             }
             ret = 1;
index e44bb32dca6fd38c9bcda4651a24c2c86d85d0f6..0b820820b8f03dda553b838e471e922748323279 100644 (file)
@@ -148,8 +148,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
                             *q = '\0';
                             break;
                         }
-                    if (c->param_port != NULL)
-                        OPENSSL_free(c->param_port);
+                    OPENSSL_free(c->param_port);
                     c->param_port = BUF_strdup(p);
                 }
             }
@@ -308,10 +307,8 @@ void BIO_CONNECT_free(BIO_CONNECT *a)
     if (a == NULL)
         return;
 
-    if (a->param_hostname != NULL)
-        OPENSSL_free(a->param_hostname);
-    if (a->param_port != NULL)
-        OPENSSL_free(a->param_port);
+    OPENSSL_free(a->param_hostname);
+    OPENSSL_free(a->param_port);
     OPENSSL_free(a);
 }
 
@@ -455,12 +452,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
         if (ptr != NULL) {
             b->init = 1;
             if (num == 0) {
-                if (data->param_hostname != NULL)
-                    OPENSSL_free(data->param_hostname);
+                OPENSSL_free(data->param_hostname);
                 data->param_hostname = BUF_strdup(ptr);
             } else if (num == 1) {
-                if (data->param_port != NULL)
-                    OPENSSL_free(data->param_port);
+                OPENSSL_free(data->param_port);
                 data->param_port = BUF_strdup(ptr);
             } else if (num == 2) {
                 char buf[16];
@@ -468,16 +463,14 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
 
                 BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
                              p[0], p[1], p[2], p[3]);
-                if (data->param_hostname != NULL)
-                    OPENSSL_free(data->param_hostname);
+                OPENSSL_free(data->param_hostname);
                 data->param_hostname = BUF_strdup(buf);
                 memcpy(&(data->ip[0]), ptr, 4);
             } else if (num == 3) {
                 char buf[DECIMAL_SIZE(int) + 1];
 
                 BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
-                if (data->param_port != NULL)
-                    OPENSSL_free(data->param_port);
+                OPENSSL_free(data->param_port);
                 data->param_port = BUF_strdup(buf);
                 data->port = *(int *)ptr;
             }
index 4fa6279d05fe8c97117ad742a879a5c15b0f182b..406d46bb6caca04b86336aa349ba745dc3c729ad 100644 (file)
@@ -245,8 +245,7 @@ static int dgram_free(BIO *a)
         return 0;
 
     data = (bio_dgram_data *)a->ptr;
-    if (data != NULL)
-        OPENSSL_free(data);
+    OPENSSL_free(data);
 
     return (1);
 }
@@ -1110,8 +1109,7 @@ static int dgram_sctp_free(BIO *a)
 
     data = (bio_dgram_sctp_data *) a->ptr;
     if (data != NULL) {
-        if (data->saved_message.data != NULL)
-            OPENSSL_free(data->saved_message.data);
+        OPENSSL_free(data->saved_message.data);
         OPENSSL_free(data);
     }
 
@@ -1413,8 +1411,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
             BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_FAILURE);
             return -1;
         }
-        if (data->saved_message.data)
-            OPENSSL_free(data->saved_message.data);
+        OPENSSL_free(data->saved_message.data);
         data->saved_message.data = tmp;
         memcpy(data->saved_message.data, in, inl);
         data->saved_message.length = inl;
index 28c36931a9a8c96a5471d9ccd6eecf87501bb32c..17aa2ba5bf325c19a006b87cd9640462d9f68f5b 100644 (file)
@@ -1131,8 +1131,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
         BN_MONT_CTX_free(mont);
     if (powerbuf != NULL) {
         OPENSSL_cleanse(powerbuf, powerbufLen);
-        if (powerbufFree)
-            OPENSSL_free(powerbufFree);
+        OPENSSL_free(powerbufFree);
     }
     BN_CTX_end(ctx);
     return (ret);
index fc7ad242969ffd9a3de7c9637d52f3c9d46bd0b2..7c0d4afc7198b6f0076a2d3e10af899e9e297109 100644 (file)
@@ -561,8 +561,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
     bn_check_top(r);
  err:
-    if (arr)
-        OPENSSL_free(arr);
+    OPENSSL_free(arr);
     return ret;
 }
 
@@ -620,8 +619,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
     ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
     bn_check_top(r);
  err:
-    if (arr)
-        OPENSSL_free(arr);
+    OPENSSL_free(arr);
     return ret;
 }
 
@@ -1037,8 +1035,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
     ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx);
     bn_check_top(r);
  err:
-    if (arr)
-        OPENSSL_free(arr);
+    OPENSSL_free(arr);
     return ret;
 }
 
@@ -1097,8 +1094,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
     ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);
     bn_check_top(r);
  err:
-    if (arr)
-        OPENSSL_free(arr);
+    OPENSSL_free(arr);
     return ret;
 }
 
@@ -1228,8 +1224,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);
     bn_check_top(r);
  err:
-    if (arr)
-        OPENSSL_free(arr);
+    OPENSSL_free(arr);
     return ret;
 }
 
index 32ad50523d5937135ae538131cdf382c2623f597..139d11b78e2b7758419ae6b716f0271a5d2678fd 100644 (file)
@@ -67,7 +67,6 @@
 signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
 {
     int window_val;
-    int ok = 0;
     signed char *r = NULL;
     int sign = 1;
     int bit, next_bit, mask;
@@ -176,17 +175,12 @@ signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
         BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
         goto err;
     }
-    len = j;
-    ok = 1;
+    *ret_len = j;
+    return r;
 
  err:
-    if (!ok) {
-        OPENSSL_free(r);
-        r = NULL;
-    }
-    if (ok)
-        *ret_len = len;
-    return r;
+    OPENSSL_free(r);
+    return NULL;
 }
 
 int bn_get_top(const BIGNUM *a)
index 2c5e2b26f8c83516ab759e632e98094577776527..3e9ea8ef4c4e9c3dc64b1216b264b2e368cc840f 100644 (file)
@@ -246,7 +246,7 @@ void BN_free(BIGNUM *a)
     if (a == NULL)
         return;
     bn_check_top(a);
-    if ((a->d != NULL) && !(BN_get_flags(a, BN_FLG_STATIC_DATA)))
+    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
         OPENSSL_free(a->d);
     if (a->flags & BN_FLG_MALLOCED)
         OPENSSL_free(a);
@@ -378,8 +378,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
         BN_ULONG *a = bn_expand_internal(b, words);
         if (!a)
             return NULL;
-        if (b->d)
-            OPENSSL_free(b->d);
+        OPENSSL_free(b->d);
         b->d = a;
         b->dmax = words;
     }
index 8b59e78916db1876285a5164829259b15a057cf1..1ef5a879c2ea36a8882e6a83e8cb54cfbddee04b 100644 (file)
@@ -156,15 +156,12 @@ char *BN_bn2dec(const BIGNUM *a)
     }
     ok = 1;
  err:
-    if (bn_data != NULL)
-        OPENSSL_free(bn_data);
+    OPENSSL_free(bn_data);
     BN_free(t);
-    if (!ok && buf) {
-        OPENSSL_free(buf);
-        buf = NULL;
-    }
-
-    return (buf);
+    if (ok)
+        return buf;
+    OPENSSL_free(buf);
+    return NULL;
 }
 
 int BN_hex2bn(BIGNUM **bn, const char *a)
index 4681154e3894e6cc74728d07b1bf51284ad3e98e..ed3c3c5911265ce85176cd13e763d82b43cdfe5b 100644 (file)
@@ -351,7 +351,6 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
     ret = 1;
 
  err:
-    if (k_bytes)
-        OPENSSL_free(k_bytes);
+    OPENSSL_free(k_bytes);
     return ret;
 }
index d146f845e9042ab1c1aea46e5143760069891192..e8274beabfe3ab1b85ed78e5d6579246c1076428 100644 (file)
@@ -404,8 +404,7 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms,
         EVP_PKEY_CTX_free(pctx);
         ktri->pctx = NULL;
     }
-    if (ek)
-        OPENSSL_free(ek);
+    OPENSSL_free(ek);
     return ret;
 
 }
@@ -472,7 +471,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
  err:
     EVP_PKEY_CTX_free(ktri->pctx);
     ktri->pctx = NULL;
-    if (!ret && ek)
+    if (!ret)
         OPENSSL_free(ek);
 
     return ret;
@@ -712,7 +711,7 @@ static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms,
 
  err:
 
-    if (!r && wkey)
+    if (!r)
         OPENSSL_free(wkey);
     OPENSSL_cleanse(&actx, sizeof(actx));
 
@@ -785,7 +784,7 @@ static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms,
 
  err:
 
-    if (!r && ukey)
+    if (!r)
         OPENSSL_free(ukey);
     OPENSSL_cleanse(&actx, sizeof(actx));
 
index 6d5fa90a06dc575e8d4cd95035f64e0ba08f96af..21f41f6a4b2add4c99aa2feb8d06224fc514fc81 100644 (file)
@@ -154,8 +154,7 @@ int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr)
     if (!r)
         CMSerr(CMS_F_CMS_ADD1_RECEIPTREQUEST, ERR_R_MALLOC_FAILURE);
 
-    if (rrder)
-        OPENSSL_free(rrder);
+    OPENSSL_free(rrder);
 
     return r;
 
index 17b62ddd8cd0bfd16ad03bcf364175c6b20c3e46..ea7fb5b8f234eb5469620b51bc23403d417afded 100644 (file)
@@ -268,7 +268,7 @@ static int cms_kek_cipher(unsigned char **pout, size_t *poutlen,
 
  err:
     OPENSSL_cleanse(kek, keklen);
-    if (!rv && out)
+    if (!rv)
         OPENSSL_free(out);
     EVP_CIPHER_CTX_cleanup(&kari->ctx);
     EVP_PKEY_CTX_free(kari->pctx);
@@ -300,8 +300,7 @@ int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
     cek = NULL;
     rv = 1;
  err:
-    if (cek)
-        OPENSSL_free(cek);
+    OPENSSL_free(cek);
     return rv;
 }
 
index 64165022f3bc0b6e57e0ce6ac9eec529b7cbbeee..1d505e9d1c88d59c9ac2379be84e7750aa526868 100644 (file)
@@ -420,7 +420,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
 
     EVP_CIPHER_CTX_cleanup(&kekctx);
 
-    if (!r && key)
+    if (!r)
         OPENSSL_free(key);
     X509_ALGOR_free(kekalg);
 
index 31398acfe334849b12f3558d80aa82da677da9f3..7fb4385f60a75198d5bcb36ab027f14cd7df770d 100644 (file)
@@ -728,8 +728,7 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si)
     return 1;
 
  err:
-    if (abuf)
-        OPENSSL_free(abuf);
+    OPENSSL_free(abuf);
     EVP_MD_CTX_cleanup(mctx);
     return 0;
 
index aa03f8fda13ee4f5b32c933b622b4e98078deae7..4508e7f6345a466075607217d87f4241c4560b51 100644 (file)
@@ -151,8 +151,7 @@ static int zlib_stateful_init(COMP_CTX *ctx)
     CRYPTO_set_ex_data(&ctx->ex_data, zlib_stateful_ex_idx, state);
     return 1;
  err:
-    if (state)
-        OPENSSL_free(state);
+    OPENSSL_free(state);
     return 0;
 }
 
@@ -606,18 +605,14 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
         }
 
         if (ibs != -1) {
-            if (ctx->ibuf) {
-                OPENSSL_free(ctx->ibuf);
-                ctx->ibuf = NULL;
-            }
+            OPENSSL_free(ctx->ibuf);
+            ctx->ibuf = NULL;
             ctx->ibufsize = ibs;
         }
 
         if (obs != -1) {
-            if (ctx->obuf) {
-                OPENSSL_free(ctx->obuf);
-                ctx->obuf = NULL;
-            }
+            OPENSSL_free(ctx->obuf);
+            ctx->obuf = NULL;
             ctx->obufsize = obs;
         }
         ret = 1;
index cba2de199b1e66a3929a33a194c7ac80d3cc09bc..b41564b6803dc79364f0344528df768a71b60aa4 100644 (file)
@@ -273,8 +273,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
     if (!ok) {
         if (sk != NULL)
             sk_CONF_VALUE_free(sk);
-        if (v != NULL)
-            OPENSSL_free(v);
+        OPENSSL_free(v);
         v = NULL;
     }
     return (v);
index ef3fef44004f0892952ccccc8e3ab34e54f99136..bd2e8c096e0153a5cf76a49f3d5d64aed18466f2 100644 (file)
@@ -393,14 +393,12 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
     }
     if (buff != NULL)
         BUF_MEM_free(buff);
-    if (section != NULL)
-        OPENSSL_free(section);
+    OPENSSL_free(section);
     return (1);
  err:
     if (buff != NULL)
         BUF_MEM_free(buff);
-    if (section != NULL)
-        OPENSSL_free(section);
+    OPENSSL_free(section);
     if (line != NULL)
         *line = eline;
     BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
@@ -410,12 +408,9 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
         conf->data = NULL;
     }
     if (v != NULL) {
-        if (v->name != NULL)
-            OPENSSL_free(v->name);
-        if (v->value != NULL)
-            OPENSSL_free(v->value);
-        if (v != NULL)
-            OPENSSL_free(v);
+        OPENSSL_free(v->name);
+        OPENSSL_free(v->value);
+        OPENSSL_free(v);
     }
     return (0);
 }
@@ -595,8 +590,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
             buf->data[to++] = *(from++);
     }
     buf->data[to] = '\0';
-    if (*pto != NULL)
-        OPENSSL_free(*pto);
+    OPENSSL_free(*pto);
     *pto = buf->data;
     OPENSSL_free(buf);
     return (1);
index 9acfca4f7198cf541d898c070dc5dfe33682a347..ce2b1778731924091ea42f47ee96cc37eb0fd4ef 100644 (file)
@@ -383,10 +383,8 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
 
  memerr:
     if (imod) {
-        if (imod->name)
-            OPENSSL_free(imod->name);
-        if (imod->value)
-            OPENSSL_free(imod->value);
+        OPENSSL_free(imod->name);
+        OPENSSL_free(imod->value);
         OPENSSL_free(imod);
     }
 
index 6a4223c1673f25362e99fb211ffd0695337565c9..c9374b77f98887360adf0c5947f05de06282d1a0 100644 (file)
@@ -187,8 +187,7 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
         return 1;
 
  err:
-    if (penc)
-        OPENSSL_free(penc);
+    OPENSSL_free(penc);
     ASN1_STRING_free(str);
 
     return 0;
@@ -292,8 +291,7 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
     return 1;
 
  err:
-    if (dp != NULL)
-        OPENSSL_free(dp);
+    OPENSSL_free(dp);
     ASN1_STRING_free(params);
     ASN1_STRING_clear_free(prkey);
     return 0;
@@ -422,8 +420,7 @@ static int do_dh_print(BIO *bp, const DH *x, int indent,
  err:
         DHerr(DH_F_DO_DH_PRINT, reason);
     }
-    if (m != NULL)
-        OPENSSL_free(m);
+    OPENSSL_free(m);
     return (ret);
 }
 
@@ -481,11 +478,9 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942)
             return 0;
         if (!int_dh_bn_cpy(&to->j, from->j))
             return 0;
-        if (to->seed) {
-            OPENSSL_free(to->seed);
-            to->seed = NULL;
-            to->seedlen = 0;
-        }
+        OPENSSL_free(to->seed);
+        to->seed = NULL;
+        to->seedlen = 0;
         if (from->seed) {
             to->seed = BUF_memdup(from->seed, from->seedlen);
             if (!to->seed)
index a882cb286e0eaed12f0dd3d672ef40454808cbf7..b812d821e4ef510c6b41434a6b8f4aad8f12b48a 100644 (file)
@@ -180,8 +180,7 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
     }
     rv = 1;
  err:
-    if (der)
-        OPENSSL_free(der);
+    OPENSSL_free(der);
     EVP_MD_CTX_cleanup(&mctx);
     return rv;
 }
index 74bad4dfcf6e81662f59c85666e88a1179890117..10e98c63eed2ca59d9bf726d3404d09eb26424ab 100644 (file)
@@ -198,8 +198,7 @@ void DH_free(DH *r)
     BN_clear_free(r->g);
     BN_clear_free(r->q);
     BN_clear_free(r->j);
-    if (r->seed)
-        OPENSSL_free(r->seed);
+    OPENSSL_free(r->seed);
     BN_clear_free(r->counter);
     BN_clear_free(r->pub_key);
     BN_clear_free(r->priv_key);
index 069b855aa06884da47097f07527876a17d4a74a3..be44c0b2016022487d8081a7456f41975814434a 100644 (file)
@@ -153,8 +153,7 @@ static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx)
 {
     DH_PKEY_CTX *dctx = ctx->data;
     if (dctx) {
-        if (dctx->kdf_ukm)
-            OPENSSL_free(dctx->kdf_ukm);
+        OPENSSL_free(dctx->kdf_ukm);
         ASN1_OBJECT_free(dctx->kdf_oid);
         OPENSSL_free(dctx);
     }
@@ -230,8 +229,7 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
         return 1;
 
     case EVP_PKEY_CTRL_DH_KDF_UKM:
-        if (dctx->kdf_ukm)
-            OPENSSL_free(dctx->kdf_ukm);
+        OPENSSL_free(dctx->kdf_ukm);
         dctx->kdf_ukm = p2;
         if (p2)
             dctx->kdf_ukmlen = p1;
index e26ca848dc76c667771215a332de80ac87108eeb..e5009ec585cf7c3f3ab11588049275df98597720 100644 (file)
@@ -169,8 +169,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
         return 1;
 
  err:
-    if (penc)
-        OPENSSL_free(penc);
+    OPENSSL_free(penc);
     ASN1_STRING_free(str);
 
     return 0;
@@ -329,8 +328,7 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
     return 1;
 
  err:
-    if (dp != NULL)
-        OPENSSL_free(dp);
+    OPENSSL_free(dp);
     ASN1_STRING_free(params);
     ASN1_STRING_clear_free(prkey);
     return 0;
@@ -471,8 +469,7 @@ static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
         goto err;
     ret = 1;
  err:
-    if (m != NULL)
-        OPENSSL_free(m);
+    OPENSSL_free(m);
     return (ret);
 }
 
@@ -562,8 +559,7 @@ static int dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
             goto err;
         rv = 1;
  err:
-        if (m)
-            OPENSSL_free(m);
+        OPENSSL_free(m);
         DSA_SIG_free(dsa_sig);
         return rv;
     }
index 1827de8d0ba1f981f98aa96dc0283f82e86848d0..59946f6579aa4df2e86f7e9159459c77e76fbd1a 100644 (file)
@@ -644,8 +644,7 @@ int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
         if (h_ret != NULL)
             *h_ret = h;
     }
-    if (seed)
-        OPENSSL_free(seed);
+    OPENSSL_free(seed);
     if (seed_out != seed_tmp)
         OPENSSL_free(seed_tmp);
     if (ctx)
index c119209ab2fcfb77f35d66d9038a207b43fb2e4d..7aa1054437d511d2fabcf9373c2617dd274e0a9d 100644 (file)
@@ -113,8 +113,7 @@ static int pkey_dsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
 static void pkey_dsa_cleanup(EVP_PKEY_CTX *ctx)
 {
     DSA_PKEY_CTX *dctx = ctx->data;
-    if (dctx)
-        OPENSSL_free(dctx);
+    OPENSSL_free(dctx);
 }
 
 static int pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
index 989d4d95878a8de2586b691362442025fa125ea9..5d5ede03a5881f5404b694efbf46acd5b250c7ea 100644 (file)
@@ -143,8 +143,7 @@ static int dl_load(DSO *dso)
     return (1);
  err:
     /* Cleanup! */
-    if (filename != NULL)
-        OPENSSL_free(filename);
+    OPENSSL_free(filename);
     if (ptr != NULL)
         shl_unload(ptr);
     return (0);
index 8ebb2b59c9811f21074f5341d699dbd0e484cb20..92d951fce38379e1cf521894c97f09ff72b6401e 100644 (file)
@@ -182,8 +182,7 @@ static int dlfcn_load(DSO *dso)
     return (1);
  err:
     /* Cleanup! */
-    if (filename != NULL)
-        OPENSSL_free(filename);
+    OPENSSL_free(filename);
     if (ptr != NULL)
         dlclose(ptr);
     return (0);
index c1d6d2544f33e4e4ba1230797cb0ba91749a3d10..a33a8a85bb2124aaa3946e1b774cd9b03c83757d 100644 (file)
@@ -162,11 +162,8 @@ int DSO_free(DSO *dso)
     }
 
     sk_void_free(dso->meth_data);
-    if (dso->filename != NULL)
-        OPENSSL_free(dso->filename);
-    if (dso->loaded_filename != NULL)
-        OPENSSL_free(dso->loaded_filename);
-
+    OPENSSL_free(dso->filename);
+    OPENSSL_free(dso->loaded_filename);
     OPENSSL_free(dso);
     return (1);
 }
@@ -360,8 +357,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
         return (0);
     }
     BUF_strlcpy(copied, filename, strlen(filename) + 1);
-    if (dso->filename)
-        OPENSSL_free(dso->filename);
+    OPENSSL_free(dso->filename);
     dso->filename = copied;
     return (1);
 }
index 79bbd9712286fa5966794935ce951ff0fccca732..821e238bd441acfd4fc1973f065958db4e886b9e 100644 (file)
@@ -267,10 +267,8 @@ static int vms_load(DSO *dso)
     return (1);
  err:
     /* Cleanup! */
-    if (p != NULL)
-        OPENSSL_free(p);
-    if (filename != NULL)
-        OPENSSL_free(filename);
+    OPENSSL_free(p);
+    OPENSSL_free(filename);
     return (0);
 }
 
index 2499fc152b2a51e757694dcf3294f39841b5512e..144d8e63c33ad5bea8033fa762afaabbcf5b6a8b 100644 (file)
@@ -183,10 +183,8 @@ static int win32_load(DSO *dso)
     return (1);
  err:
     /* Cleanup ! */
-    if (filename != NULL)
-        OPENSSL_free(filename);
-    if (p != NULL)
-        OPENSSL_free(p);
+    OPENSSL_free(filename);
+    OPENSSL_free(p);
     if (h != NULL)
         FreeLibrary(h);
     return (0);
index 0554c209e5799d060bcced5c88159b2b9fd373d9..1cc4d4003b895bc01cc3e34e68a784ce6fa89123 100644 (file)
@@ -132,8 +132,7 @@ static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
         ASN1_OBJECT_free(pval);
     else
         ASN1_STRING_free(pval);
-    if (penc)
-        OPENSSL_free(penc);
+    OPENSSL_free(penc);
     return 0;
 }
 
@@ -503,8 +502,7 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
     BN_free(pub_key);
     BN_free(order);
     BN_CTX_free(ctx);
-    if (buffer != NULL)
-        OPENSSL_free(buffer);
+    OPENSSL_free(buffer);
     return (ret);
 }
 
index 5976a2fba342f4564c2a21c336fed22f4d666470..c86f22e7d1165546412ce75c880d245c94ab114b 100644 (file)
@@ -525,10 +525,8 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
     ok = 1;
 
  err:
-    if (buffer_1)
-        OPENSSL_free(buffer_1);
-    if (buffer_2)
-        OPENSSL_free(buffer_2);
+    OPENSSL_free(buffer_1);
+    OPENSSL_free(buffer_2);
     BN_free(tmp_1);
     BN_free(tmp_2);
     return (ok);
@@ -628,8 +626,7 @@ static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *group,
     if (!param)
         ECPARAMETERS_free(ret);
     BN_free(tmp);
-    if (buffer)
-        OPENSSL_free(buffer);
+    OPENSSL_free(buffer);
     return NULL;
 }
 
@@ -840,8 +837,7 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
 
     /* extract seed (optional) */
     if (params->curve->seed != NULL) {
-        if (ret->seed != NULL)
-            OPENSSL_free(ret->seed);
+        OPENSSL_free(ret->seed);
         if (!(ret->seed = OPENSSL_malloc(params->curve->seed->length))) {
             ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE);
             goto err;
@@ -1193,8 +1189,7 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
     }
     ok = 1;
  err:
-    if (buffer)
-        OPENSSL_free(buffer);
+    OPENSSL_free(buffer);
     if (priv_key)
         EC_PRIVATEKEY_free(priv_key);
     return (ok ? ret : 0);
index 1f51f74aa988dc8ab7fb57dfa000fe6367c41baf..02de91da918a92d5e7fe1cd33ee67b6ee8218ef9 100644 (file)
@@ -232,8 +232,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
     dest->asn1_form = src->asn1_form;
 
     if (src->seed) {
-        if (dest->seed)
-            OPENSSL_free(dest->seed);
+        OPENSSL_free(dest->seed);
         dest->seed = OPENSSL_malloc(src->seed_len);
         if (dest->seed == NULL)
             return 0;
@@ -241,8 +240,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
             return 0;
         dest->seed_len = src->seed_len;
     } else {
-        if (dest->seed)
-            OPENSSL_free(dest->seed);
+        OPENSSL_free(dest->seed);
         dest->seed = NULL;
         dest->seed_len = 0;
     }
@@ -382,11 +380,9 @@ point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP
 
 size_t EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len)
 {
-    if (group->seed) {
-        OPENSSL_free(group->seed);
-        group->seed = NULL;
-        group->seed_len = 0;
-    }
+    OPENSSL_free(group->seed);
+    group->seed = NULL;
+    group->seed_len = 0;
 
     if (!len || !p)
         return 1;
index b4723fb5d544cee1f5f264294cb91435e26f370c..115bc4258b620e7059c885cae6a718a85b08f31d 100644 (file)
@@ -555,10 +555,8 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
  err:
     BN_CTX_free(new_ctx);
     EC_POINT_free(tmp);
-    if (wsize != NULL)
-        OPENSSL_free(wsize);
-    if (wNAF_len != NULL)
-        OPENSSL_free(wNAF_len);
+    OPENSSL_free(wsize);
+    OPENSSL_free(wNAF_len);
     if (wNAF != NULL) {
         signed char **w;
 
@@ -573,9 +571,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
 
         OPENSSL_free(val);
     }
-    if (val_sub != NULL) {
-        OPENSSL_free(val_sub);
-    }
+    OPENSSL_free(val_sub);
     return ret;
 }
 
index 5b3d197b69c0f79ee8541e681dccbefd55beb81e..ec27e23c68470182544ac20e3311bc550d99a091 100644 (file)
@@ -148,8 +148,7 @@ static void pkey_ec_cleanup(EVP_PKEY_CTX *ctx)
     if (dctx) {
         EC_GROUP_free(dctx->gen_group);
         EC_KEY_free(dctx->co_key);
-        if (dctx->kdf_ukm)
-            OPENSSL_free(dctx->kdf_ukm);
+        OPENSSL_free(dctx->kdf_ukm);
         OPENSSL_free(dctx);
     }
 }
@@ -359,8 +358,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
         return 1;
 
     case EVP_PKEY_CTRL_EC_KDF_UKM:
-        if (dctx->kdf_ukm)
-            OPENSSL_free(dctx->kdf_ukm);
+        OPENSSL_free(dctx->kdf_ukm);
         dctx->kdf_ukm = p2;
         if (p2)
             dctx->kdf_ukmlen = p1;
index 6eb529138a24c7e6c66096b3cf9207c7dc72746d..7cdc485b2e8a6e5fa312b5622dd7a564777ca801 100644 (file)
@@ -325,8 +325,7 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
     BN_free(order);
     BN_free(cofactor);
     BN_CTX_free(ctx);
-    if (buffer != NULL)
-        OPENSSL_free(buffer);
+    OPENSSL_free(buffer);
     return (ret);
 }
 
index fdcf4503311a1470a5ab01d4d45ae32b941ee67c..60a8d509251a2d005b325d8c1e2ad123745797fe 100644 (file)
@@ -1573,12 +1573,9 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
     BN_CTX_end(ctx);
     EC_POINT_free(generator);
     BN_CTX_free(new_ctx);
-    if (secrets != NULL)
-        OPENSSL_free(secrets);
-    if (pre_comp != NULL)
-        OPENSSL_free(pre_comp);
-    if (tmp_felems != NULL)
-        OPENSSL_free(tmp_felems);
+    OPENSSL_free(secrets);
+    OPENSSL_free(pre_comp);
+    OPENSSL_free(tmp_felems);
     return ret;
 }
 
index d03bf15d8c8e70848ff9d32d93ce17b79f7be860..c9f073b616b069ceffa7cc897d9580c441db98a2 100644 (file)
@@ -2193,12 +2193,9 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
     BN_CTX_end(ctx);
     EC_POINT_free(generator);
     BN_CTX_free(new_ctx);
-    if (secrets != NULL)
-        OPENSSL_free(secrets);
-    if (pre_comp != NULL)
-        OPENSSL_free(pre_comp);
-    if (tmp_smallfelems != NULL)
-        OPENSSL_free(tmp_smallfelems);
+    OPENSSL_free(secrets);
+    OPENSSL_free(pre_comp);
+    OPENSSL_free(tmp_smallfelems);
     return ret;
 }
 
index 1069214f6babb7288ff502e267d22c918483ca81..bdfd57662f99085beca02d5637c5d31df16a2c12 100644 (file)
@@ -2021,12 +2021,9 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
     BN_CTX_end(ctx);
     EC_POINT_free(generator);
     BN_CTX_free(new_ctx);
-    if (secrets != NULL)
-        OPENSSL_free(secrets);
-    if (pre_comp != NULL)
-        OPENSSL_free(pre_comp);
-    if (tmp_felems != NULL)
-        OPENSSL_free(tmp_felems);
+    OPENSSL_free(secrets);
+    OPENSSL_free(pre_comp);
+    OPENSSL_free(tmp_felems);
     return ret;
 }
 
index ae1fcddc1093b28d058a7d51184f83f148ed9b56..e73d26cf7df09fe7c6648e7e70b336e8203f10e9 100644 (file)
@@ -721,12 +721,9 @@ __owur static int ecp_nistz256_windowed_mul(const EC_GROUP *group,
 
     ret = 1;
  err:
-    if (table_storage)
-        OPENSSL_free(table_storage);
-    if (p_str)
-        OPENSSL_free(p_str);
-    if (scalars)
-        OPENSSL_free(scalars);
+    OPENSSL_free(table_storage);
+    OPENSSL_free(p_str);
+    OPENSSL_free(scalars);
     return ret;
 }
 
@@ -889,8 +886,7 @@ __owur static int ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx)
     BN_CTX_free(new_ctx);
 
     ecp_nistz256_pre_comp_free(pre_comp);
-    if (precomp_storage)
-        OPENSSL_free(precomp_storage);
+    OPENSSL_free(precomp_storage);
     EC_POINT_free(P);
     EC_POINT_free(T);
     return ret;
@@ -1356,10 +1352,8 @@ err:
     if (ctx)
         BN_CTX_end(ctx);
     BN_CTX_free(new_ctx);
-    if (new_points)
-        OPENSSL_free(new_points);
-    if (new_scalars)
-        OPENSSL_free(new_scalars);
+    OPENSSL_free(new_points);
+    OPENSSL_free(new_scalars);
     return ret;
 }
 
@@ -1451,9 +1445,7 @@ static void ecp_nistz256_pre_comp_free(void *pre_)
     if (i > 0)
         return;
 
-    if (pre->precomp_storage)
-        OPENSSL_free(pre->precomp_storage);
-
+    OPENSSL_free(pre->precomp_storage);
     OPENSSL_free(pre);
 }
 
index 6297706a2a226acd3a1160b66ce4c1c25e938d67..ad3482fab754b1a6db8887484ef0a352418ffdd3 100644 (file)
@@ -206,7 +206,6 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
     if (ctx)
         BN_CTX_end(ctx);
     BN_CTX_free(ctx);
-    if (buf)
-        OPENSSL_free(buf);
+    OPENSSL_free(buf);
     return (ret);
 }
index a3be0d79ed0358dd511fc0e181df1e466ff6e13b..d801ae8f1c62b5a4cccce1590ecb0fc99603385e 100644 (file)
@@ -889,11 +889,9 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
         return (0);
     }
 
-    if (state->mac_data) {
-        OPENSSL_free(state->mac_data);
-        state->mac_data = NULL;
-        state->mac_len = 0;
-    }
+    OPENSSL_free(state->mac_data);
+    state->mac_data = NULL;
+    state->mac_len = 0;
 
     if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
         printf("cryptodev_digest_cleanup: failed to close session\n");
index 31ec3244227dca66d774943b4a7db0c9fc33b084..7dd3659e76edfea086920651ad223b8907273fad 100644 (file)
@@ -136,11 +136,11 @@ struct st_dynamic_data_ctx {
      */
     dynamic_bind_engine bind_engine;
     /* The default name/path for loading the shared library */
-    const char *DYNAMIC_LIBNAME;
+    char *DYNAMIC_LIBNAME;
     /* Whether to continue loading on a version check failure */
     int no_vcheck;
     /* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */
-    const char *engine_id;
+    char *engine_id;
     /*
      * If non-zero, a successfully loaded ENGINE should be added to the
      * internal ENGINE list. If 2, the add must succeed or the entire load
@@ -188,10 +188,8 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
         dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
         if (ctx->dynamic_dso)
             DSO_free(ctx->dynamic_dso);
-        if (ctx->DYNAMIC_LIBNAME)
-            OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
-        if (ctx->engine_id)
-            OPENSSL_free((void *)ctx->engine_id);
+        OPENSSL_free(ctx->DYNAMIC_LIBNAME);
+        OPENSSL_free(ctx->engine_id);
         if (ctx->dirs)
             sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
         OPENSSL_free(ctx);
@@ -243,8 +241,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
      * If we lost the race to set the context, c is non-NULL and *ctx is the
      * context of the thread that won.
      */
-    if (c)
-        OPENSSL_free(c);
+    OPENSSL_free(c);
     return 1;
 }
 
@@ -363,8 +360,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
         /* a NULL 'p' or a string of zero-length is the same thing */
         if (p && (strlen((const char *)p) < 1))
             p = NULL;
-        if (ctx->DYNAMIC_LIBNAME)
-            OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
+        OPENSSL_free(ctx->DYNAMIC_LIBNAME);
         if (p)
             ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
         else
@@ -377,8 +373,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
         /* a NULL 'p' or a string of zero-length is the same thing */
         if (p && (strlen((const char *)p) < 1))
             p = NULL;
-        if (ctx->engine_id)
-            OPENSSL_free((void *)ctx->engine_id);
+        OPENSSL_free(ctx->engine_id);
         if (p)
             ctx->engine_id = BUF_strdup(p);
         else
index ec7da22e5bbad3c97bfe82c0623dbd2624817716..9d58f38144271b9e97c6bf0c72a400db54e0d32f 100644 (file)
@@ -478,8 +478,7 @@ static void build_SYS_str_reasons(void)
 
 #define err_clear_data(p,i) \
         do { \
-        if (((p)->err_data[i] != NULL) && \
-                (p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
+        if ((p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
                 {  \
                 OPENSSL_free((p)->err_data[i]); \
                 (p)->err_data[i]=NULL; \
index 3468b6b3fb570b3d0c9ec9aeac67993d02669d95..c2387b9aced12dc848599dd2cbcdee0e3fd67a55 100644 (file)
@@ -523,8 +523,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
 {
     EVP_CIPHER_CTX_cleanup(ctx);
-    if (ctx)
-        OPENSSL_free(ctx);
+    OPENSSL_free(ctx);
 }
 
 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
@@ -538,8 +537,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
         if (c->cipher_data)
             OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
     }
-    if (c->cipher_data)
-        OPENSSL_free(c->cipher_data);
+    OPENSSL_free(c->cipher_data);
 #ifndef OPENSSL_NO_ENGINE
     if (c->engine)
         /*
index 6a567c99245382e20ebecd49a68a569fafbf8599..66070f6806b70cf4cecff77c69c5a6a3169476d4 100644 (file)
@@ -444,8 +444,7 @@ static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
                                  storage[i]->argl, storage[i]->argp);
         }
     }
-    if (storage)
-        OPENSSL_free(storage);
+    OPENSSL_free(storage);
     return 1;
 }
 
@@ -487,8 +486,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
                                  storage[i]->argl, storage[i]->argp);
         CRYPTO_set_ex_data(to, i, ptr);
     }
-    if (storage)
-        OPENSSL_free(storage);
+    OPENSSL_free(storage);
     return 1;
 }
 
@@ -525,8 +523,7 @@ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
                                   storage[i]->argl, storage[i]->argp);
         }
     }
-    if (storage)
-        OPENSSL_free(storage);
+    OPENSSL_free(storage);
     if (ad->sk) {
         sk_void_free(ad->sk);
         ad->sk = NULL;
index 6176b38d75c3b92566d3daf7d7a6f1eb5fe70a9b..14f67a443fd1374b70d1f7ca1173af65b810b964 100644 (file)
@@ -453,8 +453,7 @@ void CRYPTO_clear_free(void *str, size_t num)
 
 void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
 {
-    if (a != NULL)
-        OPENSSL_free(a);
+    OPENSSL_free(a);
     a = OPENSSL_malloc(num);
     return (a);
 }
index 46c4f878d1933a3c0bad00f463fafe6f4cf8b91f..bca3dedd79bc19e8fa8aa820378a700a93094616 100644 (file)
@@ -276,8 +276,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
             ao[i]->obj = o;
             aop = lh_ADDED_OBJ_insert(added, ao[i]);
             /* memory leak, buit should not normally matter */
-            if (aop != NULL)
-                OPENSSL_free(aop);
+            OPENSSL_free(aop);
         }
     }
     o->flags &=
@@ -289,10 +288,8 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
     OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE);
  err:
     for (i = ADDED_DATA; i <= ADDED_NID; i++)
-        if (ao[i] != NULL)
-            OPENSSL_free(ao[i]);
-    if (o != NULL)
-        OPENSSL_free(o);
+        OPENSSL_free(ao[i]);
+    OPENSSL_free(o);
     return (NID_undef);
 }
 
index 0bcb5df506bc14ced6535f19f7b458690731c7ec..58e9a92fe407fe444cc0c6019d651f28e32c5fbe 100644 (file)
@@ -114,14 +114,10 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
     return (r);
  err:
     OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE);
-    if (ln != NULL)
-        OPENSSL_free(ln);
-    if (sn != NULL)
-        OPENSSL_free(sn);
-    if (data != NULL)
-        OPENSSL_free(data);
-    if (r != NULL)
-        OPENSSL_free(r);
+    OPENSSL_free(ln);
+    OPENSSL_free(sn);
+    OPENSSL_free(data);
+    OPENSSL_free(r);
     return (NULL);
 }
 
index 520b55afc7dda039aedd8d7dbb94cfa12512eda3..91eac9b1c04d90c4bcf2bdc0ccc46b440b4f62c4 100644 (file)
@@ -326,8 +326,7 @@ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts,
         goto err;
     ret = 1;
  err:
-    if (os.data)
-        OPENSSL_free(os.data);
+    OPENSSL_free(os.data);
     return ret;
 }
 
index 266b43b00a2fe0cfdec77afc79a4babee2e0bae6..aa10c0345c749afdb0e9fe6ee5262ea11d293526 100644 (file)
@@ -139,8 +139,7 @@ void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
     if (!rctx)
         return;
     BIO_free(rctx->mem);
-    if (rctx->iobuf)
-        OPENSSL_free(rctx->iobuf);
+    OPENSSL_free(rctx->iobuf);
     OPENSSL_free(rctx);
 }
 
index 34df9ac04ed26f0ffe3f05f122765e605dee9dac..ac64b65235805cbf6c751ffa0174447ea88b51ac 100644 (file)
@@ -273,14 +273,10 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
     OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL);
 
  err:
-    if (buf)
-        OPENSSL_free(buf);
-    if (*ppath)
-        OPENSSL_free(*ppath);
-    if (*pport)
-        OPENSSL_free(*pport);
-    if (*phost)
-        OPENSSL_free(*phost);
+    OPENSSL_free(buf);
+    OPENSSL_free(*ppath);
+    OPENSSL_free(*pport);
+    OPENSSL_free(*phost);
     return 0;
 
 }
index 0e7338bd1df59cb52873070ad04ad521119f9339..29670ed35f8a24a16c5e3e611237d5e4dd9eecb2 100644 (file)
@@ -253,14 +253,11 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
         } else {
             /* unknown */
         }
-        if (name != NULL)
-            OPENSSL_free(name);
-        if (header != NULL)
-            OPENSSL_free(header);
-        if (data != NULL)
-            OPENSSL_free(data);
+        OPENSSL_free(name);
         name = NULL;
+        OPENSSL_free(header);
         header = NULL;
+        OPENSSL_free(data);
         data = NULL;
     }
 
@@ -287,12 +284,9 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
         ret = NULL;
     }
 
-    if (name != NULL)
-        OPENSSL_free(name);
-    if (header != NULL)
-        OPENSSL_free(header);
-    if (data != NULL)
-        OPENSSL_free(data);
+    OPENSSL_free(name);
+    OPENSSL_free(header);
+    OPENSSL_free(data);
     return (ret);
 }
 
index 374273d14fd389fc11eb994d347787d81aa195f7..a3812b80d2dd7d4a227fd3a3daf6ba0bb3baf10a 100644 (file)
@@ -112,8 +112,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
 
     ret = npubk;
  err:
-    if (s != NULL)
-        OPENSSL_free(s);
+    OPENSSL_free(s);
     OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
     return (ret);
 }
@@ -181,8 +180,7 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
  err:
     EVP_MD_CTX_cleanup(&ctx->md);
     EVP_CIPHER_CTX_cleanup(&ctx->cipher);
-    if (s != NULL)
-        OPENSSL_free(s);
+    OPENSSL_free(s);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_RSA */
index 87cc7273de0b7693d433a215bfc54e8f753367d0..e16be4a2649ff987d0e3a832c13abc0f3ca064f6 100644 (file)
@@ -95,7 +95,6 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
     ret = 1;
  err:
     /* ctx has been zeroed by EVP_SignFinal() */
-    if (m != NULL)
-        OPENSSL_free(m);
+    OPENSSL_free(m);
     return (ret);
 }
index b44912bc50bef23eb6718611f858f450777bcc21..9e9c948532c0cbb16c6c7eac09721bcec8d84117 100644 (file)
@@ -285,8 +285,7 @@ static EVP_PKEY *do_b2i_bio(BIO *in, int ispub)
         ret = b2i_rsa(&p, length, bitlen, ispub);
 
  err:
-    if (buf)
-        OPENSSL_free(buf);
+    OPENSSL_free(buf);
     return ret;
 }
 
@@ -737,7 +736,7 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in,
     ret = b2i_PrivateKey(&p, keylen);
  err:
     EVP_CIPHER_CTX_cleanup(&cctx);
-    if (enctmp && saltlen)
+    if (saltlen)
         OPENSSL_free(enctmp);
     return ret;
 }
index 4bc06b95c216132b13afcec8fad978518f2b5e0c..e5ad95fb1d9efc687caa876dc38c526fea252b4f 100644 (file)
@@ -181,8 +181,7 @@ static int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri,
  err:
     EVP_PKEY_free(pkey);
     EVP_PKEY_CTX_free(pctx);
-    if (ek)
-        OPENSSL_free(ek);
+    OPENSSL_free(ek);
     return ret;
 
 }
@@ -235,7 +234,7 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
 
  err:
     EVP_PKEY_CTX_free(pctx);
-    if (!ret && ek)
+    if (!ret)
         OPENSSL_free(ek);
 
     return ret;
@@ -890,8 +889,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si)
     return 1;
 
  err:
-    if (abuf)
-        OPENSSL_free(abuf);
+    OPENSSL_free(abuf);
     EVP_MD_CTX_cleanup(&mctx);
     return 0;
 
index 38b850ae7a9bae9bb38b9d6da8dc09981b375edf..9313c93d6884deb6479a9f2e9af08c72f171b52f 100644 (file)
@@ -251,8 +251,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv)
     }
     ret = 1;
  err:
-    if (m != NULL)
-        OPENSSL_free(m);
+    OPENSSL_free(m);
     return (ret);
 }
 
index ab8f9ec07889d1f686aab6d1591b9e482676adde..d988d6c217716d72ee9cd03a2817350d4a03b46e 100644 (file)
@@ -232,10 +232,8 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
     RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
            RSA_R_OAEP_DECODING_ERROR);
  cleanup:
-    if (db != NULL)
-        OPENSSL_free(db);
-    if (em != NULL)
-        OPENSSL_free(em);
+    OPENSSL_free(db);
+    OPENSSL_free(em);
     return mlen;
 }
 
index efa1fd3e993f0200bd5b8dd0b0bd2405617016a1..1bda998ca4abe37597cce38cf05785f9cbb75456 100644 (file)
@@ -266,8 +266,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
     memcpy(to, em + msg_index, mlen);
 
  err:
-    if (em != NULL)
-        OPENSSL_free(em);
+    OPENSSL_free(em);
     if (mlen == -1)
         RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,
                RSA_R_PKCS_DECODING_ERROR);
index 866dd1601e2ab3ab21bfe0fb5f3ae654db9e5798..94dc40881dbfee1a311988047ff7bfe4b029750c 100644 (file)
@@ -136,8 +136,7 @@ static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
     dctx->md = sctx->md;
     dctx->mgf1md = sctx->mgf1md;
     if (sctx->oaep_label) {
-        if (dctx->oaep_label)
-            OPENSSL_free(dctx->oaep_label);
+        OPENSSL_free(dctx->oaep_label);
         dctx->oaep_label = BUF_memdup(sctx->oaep_label, sctx->oaep_labellen);
         if (!dctx->oaep_label)
             return 0;
@@ -161,10 +160,8 @@ static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)
     RSA_PKEY_CTX *rctx = ctx->data;
     if (rctx) {
         BN_free(rctx->pub_exp);
-        if (rctx->tbuf)
-            OPENSSL_free(rctx->tbuf);
-        if (rctx->oaep_label)
-            OPENSSL_free(rctx->oaep_label);
+        OPENSSL_free(rctx->tbuf);
+        OPENSSL_free(rctx->oaep_label);
         OPENSSL_free(rctx);
     }
 }
@@ -514,8 +511,7 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
             RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_PADDING_MODE);
             return -2;
         }
-        if (rctx->oaep_label)
-            OPENSSL_free(rctx->oaep_label);
+        OPENSSL_free(rctx->oaep_label);
         if (p2 && p1 > 0) {
             rctx->oaep_label = p2;
             rctx->oaep_labellen = p1;
index 318f5b826400c1df50d01b1525156c1647d970e8..b5055dee98c77ddd2b10c4777bf91a2a368b1a93 100644 (file)
@@ -170,8 +170,7 @@ int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
         ret = 1;
 
  err:
-    if (DB)
-        OPENSSL_free(DB);
+    OPENSSL_free(DB);
     EVP_MD_CTX_cleanup(&ctx);
 
     return ret;
@@ -279,8 +278,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
     ret = 1;
 
  err:
-    if (salt)
-        OPENSSL_free(salt);
+    OPENSSL_free(salt);
 
     return ret;
 
index d4ac91e8fb6bbbe83c2818dd1ace72c47f66cada..7611631309b19671f85cef34ad188dbd400f254a 100644 (file)
@@ -167,8 +167,7 @@ _STACK *sk_new(int (*c) (const void *, const void *))
     ret->sorted = 0;
     return (ret);
  err:
-    if (ret)
-        OPENSSL_free(ret);
+    OPENSSL_free(ret);
     return (NULL);
 }
 
@@ -318,8 +317,7 @@ void sk_free(_STACK *st)
 {
     if (st == NULL)
         return;
-    if (st->data != NULL)
-        OPENSSL_free(st->data);
+    OPENSSL_free(st->data);
     OPENSSL_free(st);
 }
 
index f949b34dfbcac7ff0c61be118aad7dccadad8e15..868710076126c9ea297ce57f77d1c9ce0b339ceb 100644 (file)
@@ -348,8 +348,7 @@ static int mem_list_end(STORE *s, void *handle)
     }
     if (context && context->search_attributes)
         sk_STORE_ATTR_INFO_free(context->search_attributes);
-    if (context)
-        OPENSSL_free(context);
+    OPENSSL_free(context);
     return 1;
 }
 
index 6732dd76ed429557ff6e5f7e582862d515f2836b..e74474a9b360a3f22a221be67fcd2419273d712f 100644 (file)
@@ -318,10 +318,8 @@ void CRYPTO_thread_setup(void)
     lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
     if (!lock_cs || !lock_count) {
         /* Nothing we can do about this...void function! */
-        if (lock_cs)
-            OPENSSL_free(lock_cs);
-        if (lock_count)
-            OPENSSL_free(lock_count);
+        OPENSSL_free(lock_cs);
+        OPENSSL_free(lock_count);
         return;
     }
     for (i = 0; i < CRYPTO_num_locks(); i++) {
index 7f0548fd88d0c9a9c02ea613122cec4393675862..029d0bb2fe537de7f31194dd1d246f6d8969421f 100644 (file)
@@ -184,12 +184,9 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
         if (ret != NULL) {
             if (ret->data != NULL)
                 sk_OPENSSL_PSTRING_free(ret->data);
-            if (ret->index != NULL)
-                OPENSSL_free(ret->index);
-            if (ret->qual != NULL)
-                OPENSSL_free(ret->qual);
-            if (ret != NULL)
-                OPENSSL_free(ret);
+            OPENSSL_free(ret->index);
+            OPENSSL_free(ret->qual);
+            OPENSSL_free(ret);
         }
         return (NULL);
     } else
@@ -350,8 +347,7 @@ void TXT_DB_free(TXT_DB *db)
                 lh_OPENSSL_STRING_free(db->index[i]);
         OPENSSL_free(db->index);
     }
-    if (db->qual != NULL)
-        OPENSSL_free(db->qual);
+    OPENSSL_free(db->qual);
     if (db->data != NULL) {
         for (i = sk_OPENSSL_PSTRING_num(db->data) - 1; i >= 0; i--) {
             /*
@@ -362,12 +358,10 @@ void TXT_DB_free(TXT_DB *db)
             max = p[db->num_fields]; /* last address */
             if (max == NULL) {  /* new row */
                 for (n = 0; n < db->num_fields; n++)
-                    if (p[n] != NULL)
-                        OPENSSL_free(p[n]);
+                    OPENSSL_free(p[n]);
             } else {
                 for (n = 0; n < db->num_fields; n++) {
-                    if (((p[n] < (char *)p) || (p[n] > max))
-                        && (p[n] != NULL))
+                    if (((p[n] < (char *)p) || (p[n] > max)))
                         OPENSSL_free(p[n]);
                 }
             }
index d2732f5bf2bfc69ff7e9910adcabc811f65b3f91..26afbd23f7b9750aebe70d3cb82d9f956f3e0f7a 100644 (file)
@@ -335,14 +335,10 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
                                     ok_chars_copy, cancel_chars_copy, 1,
                                     UIT_BOOLEAN, flags, result_buf);
  err:
-    if (prompt_copy)
-        OPENSSL_free(prompt_copy);
-    if (action_desc_copy)
-        OPENSSL_free(action_desc_copy);
-    if (ok_chars_copy)
-        OPENSSL_free(ok_chars_copy);
-    if (cancel_chars_copy)
-        OPENSSL_free(cancel_chars_copy);
+    OPENSSL_free(prompt_copy);
+    OPENSSL_free(action_desc_copy);
+    OPENSSL_free(ok_chars_copy);
+    OPENSSL_free(cancel_chars_copy);
     return -1;
 }
 
index b30fa30d5fda1e1130675f695946ea6360f8813c..31b3c3c9dc4b8ae6d25b07e8e06a0da407fdc2a2 100644 (file)
@@ -176,8 +176,7 @@ static int by_dir_hash_cmp(const BY_DIR_HASH *const *a,
 
 static void by_dir_entry_free(BY_DIR_ENTRY *ent)
 {
-    if (ent->dir)
-        OPENSSL_free(ent->dir);
+    OPENSSL_free(ent->dir);
     if (ent->hashes)
         sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
     OPENSSL_free(ent);
index 57c2606bbb680c6f161441b6fb64df234860f21d..b0d9c4de914866a88ed111d681930f98ae0eb0e3 100644 (file)
@@ -149,19 +149,13 @@ static void x509_verify_param_zero(X509_VERIFY_PARAM *param)
     paramid = param->id;
     string_stack_free(paramid->hosts);
     paramid->hosts = NULL;
-    if (paramid->peername)
-        OPENSSL_free(paramid->peername);
-    if (paramid->email) {
-        OPENSSL_free(paramid->email);
-        paramid->email = NULL;
-        paramid->emaillen = 0;
-    }
-    if (paramid->ip) {
-        OPENSSL_free(paramid->ip);
-        paramid->ip = NULL;
-        paramid->iplen = 0;
-    }
-
+    OPENSSL_free(paramid->peername);
+    OPENSSL_free(paramid->email);
+    paramid->email = NULL;
+    paramid->emaillen = 0;
+    OPENSSL_free(paramid->ip);
+    paramid->ip = NULL;
+    paramid->iplen = 0;
 }
 
 X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void)
@@ -346,8 +340,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
         tmp = NULL;
         srclen = 0;
     }
-    if (*pdest)
-        OPENSSL_free(*pdest);
+    OPENSSL_free(*pdest);
     *pdest = tmp;
     if (pdestlen)
         *pdestlen = srclen;
@@ -356,8 +349,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
 
 int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
 {
-    if (param->name)
-        OPENSSL_free(param->name);
+    OPENSSL_free(param->name);
     param->name = BUF_strdup(name);
     if (param->name)
         return 1;
index 347ab4cd7b936df1097d94bd10e6ad4cbdae3f90..fb46d4e3af7209be5897b057eb432f51f9de7bfb 100644 (file)
@@ -113,10 +113,8 @@ char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki)
     b64_str = OPENSSL_malloc(der_len * 2);
     if (!der_spki || !b64_str) {
         X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE);
-        if (der_spki != NULL)
-            OPENSSL_free(der_spki);
-        if (b64_str != NULL)
-            OPENSSL_free(b64_str);
+        OPENSSL_free(der_spki);
+        OPENSSL_free(b64_str);
         return NULL;
     }
     p = der_spki;
index cdc4c973b3ce964277c49b18eb2b3f275732555e..cab7171474983bc9ae9b2cec24aadb3e00a45b36 100644 (file)
@@ -166,8 +166,7 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
 
     BUF_MEM_free(a->bytes);
     sk_X509_NAME_ENTRY_pop_free(a->entries, X509_NAME_ENTRY_free);
-    if (a->canon_enc)
-        OPENSSL_free(a->canon_enc);
+    OPENSSL_free(a->canon_enc);
     OPENSSL_free(a);
     *pval = NULL;
 }
@@ -343,10 +342,8 @@ static int x509_name_canon(X509_NAME *a)
     X509_NAME_ENTRY *entry, *tmpentry = NULL;
     int i, set = -1, ret = 0;
 
-    if (a->canon_enc) {
-        OPENSSL_free(a->canon_enc);
-        a->canon_enc = NULL;
-    }
+    OPENSSL_free(a->canon_enc);
+    a->canon_enc = NULL;
     /* Special case: empty X509_NAME => null encoding */
     if (sk_X509_NAME_ENTRY_num(a->entries) == 0) {
         a->canon_enclen = 0;
index eb9cfea66d0ac730215d8914871f4c1cbf4b71b3..0997d599a9917177c69d55f08cd9f37a0ff8228c 100644 (file)
@@ -210,8 +210,7 @@ static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
 
  merr:
     X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE);
-    if (ext_der != NULL)
-        OPENSSL_free(ext_der);
+    OPENSSL_free(ext_der);
     ASN1_OCTET_STRING_free(ext_oct);
     return NULL;
 
@@ -305,8 +304,7 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
  err:
     ASN1_OBJECT_free(obj);
     ASN1_OCTET_STRING_free(oct);
-    if (ext_der)
-        OPENSSL_free(ext_der);
+    OPENSSL_free(ext_der);
     return extension;
 
 }
index 9d093a364d0af582e5bc1553470e021a7c45686a..633dacafc2ff69fd34cacb9de87d35e1bf263c78 100644 (file)
@@ -176,8 +176,7 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
 
  err:
     sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
-    if (value)
-        OPENSSL_free(value);
+    OPENSSL_free(value);
     if (method->it)
         ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it));
     else
index ecfc68dcb73cad009354da15d378ded99ebefc8f..2bbc05655bd22767888b17d35527575858c9f060 100644 (file)
@@ -163,8 +163,7 @@ static void SCT_free(SCT *sct)
 {
     if (!sct)
         return;
-    if (sct->sct)
-        OPENSSL_free(sct->sct);
+    OPENSSL_free(sct->sct);
     OPENSSL_free(sct);
 }
 
index 5de60ce848f1de4b694cffec3da495bda2e1311b..71422083e7ec850278a5682446b72daa15aa0c33 100644 (file)
@@ -100,12 +100,9 @@ int X509V3_add_value(const char *name, const char *value,
     return 1;
  err:
     X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE);
-    if (vtmp)
-        OPENSSL_free(vtmp);
-    if (tname)
-        OPENSSL_free(tname);
-    if (tvalue)
-        OPENSSL_free(tvalue);
+    OPENSSL_free(vtmp);
+    OPENSSL_free(tname);
+    OPENSSL_free(tvalue);
     return 0;
 }
 
@@ -121,12 +118,9 @@ void X509V3_conf_free(CONF_VALUE *conf)
 {
     if (!conf)
         return;
-    if (conf->name)
-        OPENSSL_free(conf->name);
-    if (conf->value)
-        OPENSSL_free(conf->value);
-    if (conf->section)
-        OPENSSL_free(conf->section);
+    OPENSSL_free(conf->name);
+    OPENSSL_free(conf->value);
+    OPENSSL_free(conf->section);
     OPENSSL_free(conf);
 }
 
@@ -472,8 +466,7 @@ unsigned char *string_to_hex(const char *str, long *len)
     return hexbuf;
 
  err:
-    if (hexbuf)
-        OPENSSL_free(hexbuf);
+    OPENSSL_free(hexbuf);
     X509V3err(X509V3_F_STRING_TO_HEX, ERR_R_MALLOC_FAILURE);
     return NULL;
 
@@ -1108,8 +1101,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
     return ret;
 
  err:
-    if (iptmp)
-        OPENSSL_free(iptmp);
+    OPENSSL_free(iptmp);
     ASN1_OCTET_STRING_free(ret);
     return NULL;
 }
index 2fa4e980cee327f395dcabed673f18f032359dee..c01107f4a0bebf50becc4ef0ae0efe1bf6358eee 100644 (file)
@@ -239,10 +239,8 @@ char **argv;
         BIO_printf(bio_err, "bytes written:%8ld\n", BIO_number_written(out));
     }
  end:
-    if (strbuf != NULL)
-        OPENSSL_free(strbuf);
-    if (buff != NULL)
-        OPENSSL_free(buff);
+    OPENSSL_free(strbuf);
+    OPENSSL_free(buff);
     BIO_free(in);
     BIO_free(out);
     BIO_free(benc);
index d675ace9262241f434f278738abd561a33ee3aa4..0b7221746557ca52b89870e2e57d42873857b6f7 100644 (file)
@@ -1548,12 +1548,9 @@ static int engine_md_cleanup(EVP_MD_CTX *ctx)
 
     ZEN_MD_DATA *zen_md_data = (ZEN_MD_DATA *)ctx->md_data;
 
-    if (zen_md_data->HashBuffer != NULL) {
-        OPENSSL_free(zen_md_data->HashBuffer);
-        zen_md_data->HashBufferSize = 0;
-        ctx->md_data = NULL;
-    }
-
+    OPENSSL_free(zen_md_data->HashBuffer);
+    zen_md_data->HashBufferSize = 0;
+    ctx->md_data = NULL;
     return 1;
 }
 
index 0b694f5cf165920b4c7967f991b4781a1b8612ba..b6c47f086b0c43b43e8dc8d51b1c6940ad2cb143 100644 (file)
@@ -848,9 +848,7 @@ static int pkey_bits_gost(const EVP_PKEY *pk)
 /* ---------------------- ASN1 METHOD for GOST MAC  -------------------*/
 static void mackey_free_gost(EVP_PKEY *pk)
 {
-    if (pk->pkey.ptr) {
-        OPENSSL_free(pk->pkey.ptr);
-    }
+    OPENSSL_free(pk->pkey.ptr);
 }
 
 static int mac_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
index 6c93c4584d6ddd2cfa63d9d877e1e01e2a5b9703..31b95a0d21bd8479dd531b07f34f0466201c4ef8 100644 (file)
@@ -38,11 +38,11 @@ const ENGINE_CMD_DEFN gost_cmds[] = {
 void gost_param_free()
 {
     int i;
-    for (i = 0; i <= GOST_PARAM_MAX; i++)
-        if (gost_params[i] != NULL) {
-            OPENSSL_free(gost_params[i]);
-            gost_params[i] = NULL;
-        }
+
+    for (i = 0; i <= GOST_PARAM_MAX; i++) {
+        OPENSSL_free(gost_params[i]);
+        gost_params[i] = NULL;
+    }
 
 }
 
@@ -66,8 +66,7 @@ const char *get_gost_engine_param(int param)
     }
     tmp = getenv(gost_envnames[param]);
     if (tmp) {
-        if (gost_params[param])
-            OPENSSL_free(gost_params[param]);
+        OPENSSL_free(gost_params[param]);
         gost_params[param] = BUF_strdup(tmp);
         return gost_params[param];
     }
@@ -85,8 +84,7 @@ int gost_set_default_param(int param, const char *value)
      */
     if (!tmp)
         tmp = value;
-    if (gost_params[param])
-        OPENSSL_free(gost_params[param]);
+    OPENSSL_free(gost_params[param]);
     gost_params[param] = BUF_strdup(tmp);
 
     return 1;
index 673b5387ae3e065c706d26c81e2e24444c735eff..416f0f986b5e33ba4eed94c10d8cfb6de479cfbe 100644 (file)
@@ -66,8 +66,8 @@ static int pkey_gost_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
 static void pkey_gost_cleanup(EVP_PKEY_CTX *ctx)
 {
     struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
-    if (data->shared_ukm)
-        OPENSSL_free(data->shared_ukm);
+
+    OPENSSL_free(data->shared_ukm);
     OPENSSL_free(data);
 }
 
index b605a79cfffd1172747493255227ef8bcd16949b..9c98129d98ad1360cb51cbc1d2bad56a10afe953 100644 (file)
@@ -474,8 +474,7 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE *e, const char *key_id,
 
     return res;
  err:
-    if (keyToken)
-        OPENSSL_free(keyToken);
+    OPENSSL_free(keyToken);
     return NULL;
 }
 
@@ -544,8 +543,7 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE *e, const char *key_id,
 
     return res;
  err:
-    if (keyToken)
-        OPENSSL_free(keyToken);
+    OPENSSL_free(keyToken);
     return NULL;
 }
 
@@ -924,8 +922,7 @@ static int cca_get_random_bytes(unsigned char *buf, int num)
 static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
                         long argl, void *argp)
 {
-    if (item)
-        OPENSSL_free(item);
+    OPENSSL_free(item);
 }
 #  endif
 
index 93a4be73aec9dd96996d1a0c6e953ac0a19d52c3..c86b34adbbb5e686996becec107d17734653dfd3 100644 (file)
@@ -403,8 +403,7 @@ static const char *get_AEP_LIBNAME(void)
 
 static void free_AEP_LIBNAME(void)
 {
-    if (AEP_LIBNAME)
-        OPENSSL_free((void *)AEP_LIBNAME);
+    OPENSSL_free(AEP_LIBNAME);
     AEP_LIBNAME = NULL;
 }
 
index 6a324e6766b063606af2154aa308706e80d4dbff..e9a6134871a2cf245bf4f92014e33d070f2b4970 100644 (file)
@@ -324,8 +324,7 @@ static const char *get_ATALLA_LIBNAME(void)
 
 static void free_ATALLA_LIBNAME(void)
 {
-    if (ATALLA_LIBNAME)
-        OPENSSL_free((void *)ATALLA_LIBNAME);
+    OPENSSL_free(ATALLA_LIBNAME);
     ATALLA_LIBNAME = NULL;
 }
 
index 2373d6903337a3c48536ce4f0cccf9afd0c8ba81..89e6d1d055fa25aa087adeb449899d387e45a961 100644 (file)
@@ -360,8 +360,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
         break;
 
     case CAPI_CMD_STORE_NAME:
-        if (ctx->storename)
-            OPENSSL_free(ctx->storename);
+        OPENSSL_free(ctx->storename);
         ctx->storename = BUF_strdup(p);
         CAPI_trace(ctx, "Setting store name to %s\n", p);
         break;
@@ -751,8 +750,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
     }
 
  err:
-    if (pubkey)
-        OPENSSL_free(pubkey);
+    OPENSSL_free(pubkey);
     if (!ret) {
         RSA_free(rkey);
         DSA_free(dkey);
@@ -1232,8 +1230,7 @@ static int capi_list_containers(CAPI_CTX * ctx, BIO *out)
     ret = 0;
 
  done:
-    if (cname)
-        OPENSSL_free(cname);
+    OPENSSL_free(cname);
     CryptReleaseContext(hprov, 0);
 
     return ret;
@@ -1282,10 +1279,8 @@ static void capi_dump_prov_info(CAPI_CTX * ctx, BIO *out,
     BIO_printf(out, "    Container Name: %s, Key Type %d\n", contname,
                pinfo->dwKeySpec);
  err:
-    if (provname)
-        OPENSSL_free(provname);
-    if (contname)
-        OPENSSL_free(contname);
+    OPENSSL_free(provname);
+    OPENSSL_free(contname);
 }
 
 char *capi_cert_get_fname(CAPI_CTX * ctx, PCCERT_CONTEXT cert)
@@ -1346,8 +1341,7 @@ void capi_dump_cert(CAPI_CTX * ctx, BIO *out, PCCERT_CONTEXT cert)
         CRYPT_KEY_PROV_INFO *pinfo;
         pinfo = capi_get_prov_info(ctx, cert);
         capi_dump_prov_info(ctx, out, pinfo);
-        if (pinfo)
-            OPENSSL_free(pinfo);
+        OPENSSL_free(pinfo);
     }
 
     if (flags & CAPI_DMP_PEM)
@@ -1462,10 +1456,8 @@ static CAPI_KEY *capi_get_key(CAPI_CTX * ctx, const TCHAR *contname,
 
         CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
                    _contname, _provname, ptype);
-        if (_provname)
-            OPENSSL_free(_provname);
-        if (_contname)
-            OPENSSL_free(_contname);
+        OPENSSL_free(_provname);
+        OPENSSL_free(_contname);
     }
     if (ctx->store_flags & CERT_SYSTEM_STORE_LOCAL_MACHINE)
         dwFlags = CRYPT_MACHINE_KEYSET;
@@ -1511,12 +1503,9 @@ static CAPI_KEY *capi_get_cert_key(CAPI_CTX * ctx, PCCERT_CONTEXT cert)
     }
 
  err:
-    if (pinfo)
-        OPENSSL_free(pinfo);
-    if (provname)
-        OPENSSL_free(provname);
-    if (contname)
-        OPENSSL_free(contname);
+    OPENSSL_free(pinfo);
+    OPENSSL_free(provname);
+    OPENSSL_free(contname);
     return key;
 }
 
@@ -1610,14 +1599,10 @@ static void capi_ctx_free(CAPI_CTX * ctx)
     CAPI_trace(ctx, "Calling capi_ctx_free with %lx\n", ctx);
     if (!ctx)
         return;
-    if (ctx->cspname)
-        OPENSSL_free(ctx->cspname);
-    if (ctx->debug_file)
-        OPENSSL_free(ctx->debug_file);
-    if (ctx->storename)
-        OPENSSL_free(ctx->storename);
-    if (ctx->ssl_client_store)
-        OPENSSL_free(ctx->ssl_client_store);
+    OPENSSL_free(ctx->cspname);
+    OPENSSL_free(ctx->debug_file);
+    OPENSSL_free(ctx->storename);
+    OPENSSL_free(ctx->ssl_client_store);
     OPENSSL_free(ctx);
 }
 
@@ -1647,8 +1632,7 @@ static int capi_ctx_set_provname(CAPI_CTX * ctx, LPSTR pname, DWORD type,
         }
         CryptReleaseContext(hprov, 0);
     }
-    if (ctx->cspname)
-        OPENSSL_free(ctx->cspname);
+    OPENSSL_free(ctx->cspname);
     ctx->cspname = BUF_strdup(pname);
     ctx->csptype = type;
     return 1;
index 68c9145407c81ef26c907d285cccdc82f31e5705..35352140af7585549fadb37d67aa76b0496786cb 100644 (file)
@@ -462,8 +462,7 @@ static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
 static const char *HWCRHK_LIBNAME = NULL;
 static void free_HWCRHK_LIBNAME(void)
 {
-    if (HWCRHK_LIBNAME)
-        OPENSSL_free((void *)HWCRHK_LIBNAME);
+    OPENSSL_free(HWCRHK_LIBNAME);
     HWCRHK_LIBNAME = NULL;
 }
 
index 848d10f0181f623ee18eb202ae4d730fd1417c6d..0b4bfc503e67cf4e797017bd701dfd44c0135f7d 100644 (file)
@@ -338,8 +338,7 @@ static const char *get_CSWIFT_LIBNAME(void)
 
 static void free_CSWIFT_LIBNAME(void)
 {
-    if (CSWIFT_LIBNAME)
-        OPENSSL_free((void *)CSWIFT_LIBNAME);
+    OPENSSL_free(CSWIFT_LIBNAME);
     CSWIFT_LIBNAME = NULL;
 }
 
@@ -707,16 +706,11 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
     to_return = 1;
  err:
-    if (sw_param.up.crt.p.value)
-        OPENSSL_free(sw_param.up.crt.p.value);
-    if (sw_param.up.crt.q.value)
-        OPENSSL_free(sw_param.up.crt.q.value);
-    if (sw_param.up.crt.dmp1.value)
-        OPENSSL_free(sw_param.up.crt.dmp1.value);
-    if (sw_param.up.crt.dmq1.value)
-        OPENSSL_free(sw_param.up.crt.dmq1.value);
-    if (sw_param.up.crt.iqmp.value)
-        OPENSSL_free(sw_param.up.crt.iqmp.value);
+    OPENSSL_free(sw_param.up.crt.p.value);
+    OPENSSL_free(sw_param.up.crt.q.value);
+    OPENSSL_free(sw_param.up.crt.dmp1.value);
+    OPENSSL_free(sw_param.up.crt.dmq1.value);
+    OPENSSL_free(sw_param.up.crt.iqmp.value);
     BN_free(result);
     BN_free(argument);
     if (acquired)
index 3437f3604f68cb42878def44ae072b3553e6540a..01229b0428e2ca6daec7e282e36b0f186686ccc5 100644 (file)
@@ -90,8 +90,7 @@ static const char *get_NURON_LIBNAME(void)
 
 static void free_NURON_LIBNAME(void)
 {
-    if (NURON_LIBNAME)
-        OPENSSL_free((void *)NURON_LIBNAME);
+    OPENSSL_free(NURON_LIBNAME);
     NURON_LIBNAME = NULL;
 }
 
index 9e2662e981213d8e3de238416674aeeffeaf1f88..c7eb892cf4f881d32b14e70268ba38ee224f80de 100644 (file)
@@ -339,8 +339,7 @@ static const char *get_UBSEC_LIBNAME(void)
 
 static void free_UBSEC_LIBNAME(void)
 {
-    if (UBSEC_LIBNAME)
-        OPENSSL_free((void *)UBSEC_LIBNAME);
+    OPENSSL_free(UBSEC_LIBNAME);
     UBSEC_LIBNAME = NULL;
 }
 
index da98ea03d892f82f4e153ca2844102bf53c40b98..284d3ad133a0e6e15f167b75c4169de81eb4b803 100644 (file)
@@ -130,8 +130,7 @@ static int ssl_free(BIO *a)
         a->init = 0;
         a->flags = 0;
     }
-    if (a->ptr != NULL)
-        OPENSSL_free(a->ptr);
+    OPENSSL_free(a->ptr);
     return (1);
 }
 
index 2a76474b983b9bcccafaf15d098332c6bddff41d..7b7f8760d18a73c9d6f864eef004e29a349d00b6 100644 (file)
@@ -189,8 +189,7 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
     if (reassembly) {
         bitmask = OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
         if (bitmask == NULL) {
-            if (buf != NULL)
-                OPENSSL_free(buf);
+            OPENSSL_free(buf);
             OPENSSL_free(frag);
             return NULL;
         }
@@ -211,10 +210,8 @@ void dtls1_hm_fragment_free(hm_fragment *frag)
         EVP_MD_CTX_destroy(frag->msg_header.
                            saved_retransmit_state.write_hash);
     }
-    if (frag->fragment)
-        OPENSSL_free(frag->fragment);
-    if (frag->reassembly)
-        OPENSSL_free(frag->reassembly);
+    OPENSSL_free(frag->fragment);
+    OPENSSL_free(frag->reassembly);
     OPENSSL_free(frag);
 }
 
index 3183bcf79c75726ffacb2b5c3ce03603d0aae553..a78f150c34fa2efc2e811b7cabefb8f66936c58a 100644 (file)
@@ -177,27 +177,21 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
     
     while ((item = pqueue_pop(d->unprocessed_rcds.q)) != NULL) {
         rdata = (DTLS1_RECORD_DATA *)item->data;
-        if (rdata->rbuf.buf) {
-            OPENSSL_free(rdata->rbuf.buf);
-        }
+        OPENSSL_free(rdata->rbuf.buf);
         OPENSSL_free(item->data);
         pitem_free(item);
     }
 
     while ((item = pqueue_pop(d->processed_rcds.q)) != NULL) {
         rdata = (DTLS1_RECORD_DATA *)item->data;
-        if (rdata->rbuf.buf) {
-            OPENSSL_free(rdata->rbuf.buf);
-        }
+        OPENSSL_free(rdata->rbuf.buf);
         OPENSSL_free(item->data);
         pitem_free(item);
     }
 
     while ((item = pqueue_pop(d->buffered_app_data.q)) != NULL) {
         rdata = (DTLS1_RECORD_DATA *)item->data;
-        if (rdata->rbuf.buf) {
-            OPENSSL_free(rdata->rbuf.buf);
-        }
+        OPENSSL_free(rdata->rbuf.buf);
         OPENSSL_free(item->data);
         pitem_free(item);
     }
@@ -271,8 +265,7 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
     rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA));
     item = pitem_new(priority, rdata);
     if (rdata == NULL || item == NULL) {
-        if (rdata != NULL)
-            OPENSSL_free(rdata);
+        OPENSSL_free(rdata);
         if (item != NULL)
             pitem_free(item);
 
@@ -304,8 +297,7 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
 
     if (!ssl3_setup_buffers(s)) {
         SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
-        if (rdata->rbuf.buf != NULL)
-            OPENSSL_free(rdata->rbuf.buf);
+        OPENSSL_free(rdata->rbuf.buf);
         OPENSSL_free(rdata);
         pitem_free(item);
         return (-1);
@@ -314,8 +306,7 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
     /* insert should not fail, since duplicates are dropped */
     if (pqueue_insert(queue->q, item) == NULL) {
         SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
-        if (rdata->rbuf.buf != NULL)
-            OPENSSL_free(rdata->rbuf.buf);
+        OPENSSL_free(rdata->rbuf.buf);
         OPENSSL_free(rdata);
         pitem_free(item);
         return (-1);
index 732420e27b3c0b2759bcbe8c13a44b9557a13665..5a8d34c6fb50495dc307a859463173be2bf686f9 100644 (file)
@@ -122,8 +122,7 @@ void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n)
 
 void SSL3_BUFFER_release(SSL3_BUFFER *b)
 {
-    if (b->buf != NULL)
-        OPENSSL_free(b->buf);
+    OPENSSL_free(b->buf);
     b->buf = NULL;
 }
 
@@ -224,10 +223,8 @@ int ssl3_release_write_buffer(SSL *s)
 
     wb = RECORD_LAYER_get_wbuf(&s->rlayer);
 
-    if (wb->buf != NULL) {
-        OPENSSL_free(wb->buf);
-        wb->buf = NULL;
-    }
+    OPENSSL_free(wb->buf);
+    wb->buf = NULL;
     return 1;
 }
 
@@ -236,9 +233,7 @@ int ssl3_release_read_buffer(SSL *s)
     SSL3_BUFFER *b;
 
     b = RECORD_LAYER_get_rbuf(&s->rlayer);
-    if (b->buf != NULL) {
-        OPENSSL_free(b->buf);
-        b->buf = NULL;
-    }
+    OPENSSL_free(b->buf);
+    b->buf = NULL;
     return 1;
 }
index 33d0b302f0cdd7cd618ac049e138f41fa469b95d..1e6f88ea1e57e52f79f0931f74dec925b9119e5f 100644 (file)
@@ -139,8 +139,7 @@ void SSL3_RECORD_clear(SSL3_RECORD *r)
 
 void SSL3_RECORD_release(SSL3_RECORD *r)
 {
-    if (r->comp != NULL)
-        OPENSSL_free(r->comp);
+    OPENSSL_free(r->comp);
     r->comp = NULL;
 }
 
index 71756cda2ee8e208759001f2d3d6fc0beafa4c74..52ddec14550593a8b9c17e02e74a3313f2b2af4a 100644 (file)
@@ -1401,8 +1401,7 @@ int ssl3_get_key_exchange(SSL *s)
          */
         if (alg_k & SSL_kPSK) {
             s->session->sess_cert = ssl_sess_cert_new();
-            if (s->ctx->psk_identity_hint)
-                OPENSSL_free(s->ctx->psk_identity_hint);
+            OPENSSL_free(s->ctx->psk_identity_hint);
             s->ctx->psk_identity_hint = NULL;
         }
 #endif
@@ -1471,8 +1470,7 @@ int ssl3_get_key_exchange(SSL *s)
          */
         memcpy(tmp_id_hint, p, i);
         memset(tmp_id_hint + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i);
-        if (s->ctx->psk_identity_hint != NULL)
-            OPENSSL_free(s->ctx->psk_identity_hint);
+        OPENSSL_free(s->ctx->psk_identity_hint);
         s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint);
         if (s->ctx->psk_identity_hint == NULL) {
             al = SSL_AD_HANDSHAKE_FAILURE;
@@ -2054,10 +2052,8 @@ int ssl3_get_certificate_request(SSL *s)
 
     /* get the certificate types */
     ctype_num = *(p++);
-    if (s->cert->ctypes) {
-        OPENSSL_free(s->cert->ctypes);
-        s->cert->ctypes = NULL;
-    }
+    OPENSSL_free(s->cert->ctypes);
+    s->cert->ctypes = NULL;
     if (ctype_num > SSL3_CT_NUMBER) {
         /* If we exceed static buffer copy all to cert structure */
         s->cert->ctypes = OPENSSL_malloc(ctype_num);
@@ -2193,10 +2189,8 @@ int ssl3_get_new_session_ticket(SSL *s)
         SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);
         goto f_err;
     }
-    if (s->session->tlsext_tick) {
-        OPENSSL_free(s->session->tlsext_tick);
-        s->session->tlsext_ticklen = 0;
-    }
+    OPENSSL_free(s->session->tlsext_tick);
+    s->session->tlsext_ticklen = 0;
     s->session->tlsext_tick = OPENSSL_malloc(ticklen);
     if (!s->session->tlsext_tick) {
         SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);
@@ -2257,8 +2251,7 @@ int ssl3_get_cert_status(SSL *s)
         SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_LENGTH_MISMATCH);
         goto f_err;
     }
-    if (s->tlsext_ocsp_resp)
-        OPENSSL_free(s->tlsext_ocsp_resp);
+    OPENSSL_free(s->tlsext_ocsp_resp);
     s->tlsext_ocsp_resp = BUF_memdup(p, resplen);
     if (!s->tlsext_ocsp_resp) {
         al = SSL_AD_INTERNAL_ERROR;
@@ -2786,8 +2779,7 @@ int ssl3_send_client_key_exchange(SSL *s)
 
             /* Free allocated memory */
             BN_CTX_free(bn_ctx);
-            if (encodedPoint != NULL)
-                OPENSSL_free(encodedPoint);
+            OPENSSL_free(encodedPoint);
             EC_KEY_free(clnt_ecdh);
             EVP_PKEY_free(srvr_pub_pkey);
         }
@@ -2919,8 +2911,7 @@ int ssl3_send_client_key_exchange(SSL *s)
                        ERR_R_INTERNAL_ERROR);
                 goto err;
             }
-            if (s->session->srp_username != NULL)
-                OPENSSL_free(s->session->srp_username);
+            OPENSSL_free(s->session->srp_username);
             s->session->srp_username = BUF_strdup(s->srp_ctx.login);
             if (s->session->srp_username == NULL) {
                 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
@@ -2985,8 +2976,7 @@ int ssl3_send_client_key_exchange(SSL *s)
             t += psk_len;
             s2n(psk_len, t);
 
-            if (s->session->psk_identity_hint != NULL)
-                OPENSSL_free(s->session->psk_identity_hint);
+            OPENSSL_free(s->session->psk_identity_hint);
             s->session->psk_identity_hint =
                 BUF_strdup(s->ctx->psk_identity_hint);
             if (s->ctx->psk_identity_hint != NULL
@@ -2996,8 +2986,7 @@ int ssl3_send_client_key_exchange(SSL *s)
                 goto psk_err;
             }
 
-            if (s->session->psk_identity != NULL)
-                OPENSSL_free(s->session->psk_identity);
+            OPENSSL_free(s->session->psk_identity);
             s->session->psk_identity = BUF_strdup(identity);
             if (s->session->psk_identity == NULL) {
                 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
@@ -3090,8 +3079,7 @@ int ssl3_send_client_key_exchange(SSL *s)
     s->cert->pms = NULL;
 #ifndef OPENSSL_NO_EC
     BN_CTX_free(bn_ctx);
-    if (encodedPoint != NULL)
-        OPENSSL_free(encodedPoint);
+    OPENSSL_free(encodedPoint);
     EC_KEY_free(clnt_ecdh);
     EVP_PKEY_free(srvr_pub_pkey);
 #endif
index 190d0f1b93c9a2e78a10a2fa08e23569a84bd7b0..16a60c6167a953de5b73b240665d8bb281085ce1 100644 (file)
@@ -3187,11 +3187,9 @@ void ssl3_clear(SSL *s)
     s->version = SSL3_VERSION;
 
 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
-    if (s->next_proto_negotiated) {
-        OPENSSL_free(s->next_proto_negotiated);
-        s->next_proto_negotiated = NULL;
-        s->next_proto_negotiated_len = 0;
-    }
+    OPENSSL_free(s->next_proto_negotiated);
+    s->next_proto_negotiated = NULL;
+    s->next_proto_negotiated_len = 0;
 #endif
 }
 
@@ -3331,8 +3329,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
 #ifndef OPENSSL_NO_TLSEXT
     case SSL_CTRL_SET_TLSEXT_HOSTNAME:
         if (larg == TLSEXT_NAMETYPE_host_name) {
-            if (s->tlsext_hostname != NULL)
-                OPENSSL_free(s->tlsext_hostname);
+            OPENSSL_free(s->tlsext_hostname);
             s->tlsext_hostname = NULL;
 
             ret = 1;
@@ -3386,8 +3383,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
         return s->tlsext_ocsp_resplen;
 
     case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
-        if (s->tlsext_ocsp_resp)
-            OPENSSL_free(s->tlsext_ocsp_resp);
+        OPENSSL_free(s->tlsext_ocsp_resp);
         s->tlsext_ocsp_resp = parg;
         s->tlsext_ocsp_resplen = larg;
         ret = 1;
@@ -3833,8 +3829,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
 # ifndef OPENSSL_NO_SRP
     case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
         ctx->srp_ctx.srp_Mask |= SSL_kSRP;
-        if (ctx->srp_ctx.login != NULL)
-            OPENSSL_free(ctx->srp_ctx.login);
+        OPENSSL_free(ctx->srp_ctx.login);
         ctx->srp_ctx.login = NULL;
         if (parg == NULL)
             break;
@@ -4281,10 +4276,8 @@ int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
 
 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
 {
-    if (c->ctypes) {
-        OPENSSL_free(c->ctypes);
-        c->ctypes = NULL;
-    }
+    OPENSSL_free(c->ctypes);
+    c->ctypes = NULL;
     if (!p || !len)
         return 1;
     if (len > 0xff)
index 77420a1e7a8d44f09c3f734e05bd88a97ccfa214..3e5c57af5ed490c5918e33d50847e2153f27e889 100644 (file)
@@ -2019,8 +2019,7 @@ int ssl3_send_server_key_exchange(SSL *s)
     ssl3_send_alert(s, SSL3_AL_FATAL, al);
  err:
 #ifndef OPENSSL_NO_EC
-    if (encodedPoint != NULL)
-        OPENSSL_free(encodedPoint);
+    OPENSSL_free(encodedPoint);
     BN_CTX_free(bn_ctx);
 #endif
     EVP_MD_CTX_cleanup(&md_ctx);
@@ -2763,16 +2762,14 @@ int ssl3_get_client_key_exchange(SSL *s)
         t += psk_len;
         s2n(psk_len, t);
 
-        if (s->session->psk_identity != NULL)
-            OPENSSL_free(s->session->psk_identity);
+        OPENSSL_free(s->session->psk_identity);
         s->session->psk_identity = BUF_strdup((char *)p);
         if (s->session->psk_identity == NULL) {
             SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
             goto psk_err;
         }
 
-        if (s->session->psk_identity_hint != NULL)
-            OPENSSL_free(s->session->psk_identity_hint);
+        OPENSSL_free(s->session->psk_identity_hint);
         s->session->psk_identity_hint = BUF_strdup(s->ctx->psk_identity_hint);
         if (s->ctx->psk_identity_hint != NULL &&
             s->session->psk_identity_hint == NULL) {
@@ -2821,8 +2818,7 @@ int ssl3_get_client_key_exchange(SSL *s)
                    SSL_R_BAD_SRP_PARAMETERS);
             goto f_err;
         }
-        if (s->session->srp_username != NULL)
-            OPENSSL_free(s->session->srp_username);
+        OPENSSL_free(s->session->srp_username);
         s->session->srp_username = BUF_strdup(s->srp_ctx.login);
         if (s->session->srp_username == NULL) {
             SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
@@ -3473,8 +3469,7 @@ int ssl3_send_newsession_ticket(SSL *s)
     /* SSL3_ST_SW_SESSION_TICKET_B */
     return ssl_do_write(s);
  err:
-    if (senc)
-        OPENSSL_free(senc);
+    OPENSSL_free(senc);
     EVP_CIPHER_CTX_cleanup(&ctx);
     HMAC_CTX_cleanup(&hctx);
     return -1;
index b6e784924d5e9dcc6e5543d66f20daa77719f8d5..2a07a9b596d0ab6143b93556c56078193e56b785 100644 (file)
@@ -285,10 +285,8 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
 
 static int ssl_session_strndup(char **pdst, ASN1_OCTET_STRING *src)
 {
-    if (*pdst) {
-        OPENSSL_free(*pdst);
-        *pdst = NULL;
-    }
+    OPENSSL_free(*pdst);
+    *pdst = NULL;
     if (src == NULL)
         return 1;
     *pdst = BUF_strndup((char *)src->data, src->length);
index 14decbc149b4a107843ee8077d731975f6aa3048..41af4f663ec9c4976849d1279b9bd19ff91b110e 100644 (file)
@@ -1560,7 +1560,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK
     if (ok && (strlen(rule_p) > 0))
         ok = ssl_cipher_process_rulestr(rule_p, &head, &tail, ca_list, c);
 
-    OPENSSL_free((void *)ca_list); /* Not needed anymore */
+    OPENSSL_free(ca_list); /* Not needed anymore */
 
     if (!ok) {                  /* Rule processing failure */
         OPENSSL_free(co_list);
index 97b4fb9414f5c7d43cf156a1cefce887d1323945..5a19a75dbf9d683e31e30b4b40f3104d58efb3d5 100644 (file)
@@ -380,8 +380,7 @@ static int cmd_Certificate(SSL_CONF_CTX *cctx, const char *value)
     }
     if (rv > 0 && c && cctx->flags & SSL_CONF_FLAG_REQUIRE_PRIVATE) {
         char **pfilename = &cctx->cert_filename[c->key - c->pkeys];
-        if (*pfilename)
-            OPENSSL_free(*pfilename);
+        OPENSSL_free(*pfilename);
         *pfilename = BUF_strdup(value);
         if (!*pfilename)
             rv = 0;
@@ -659,11 +658,9 @@ void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx)
     if (cctx) {
         size_t i;
         for (i = 0; i < SSL_PKEY_NUM; i++) {
-            if (cctx->cert_filename[i])
-                OPENSSL_free(cctx->cert_filename[i]);
+            OPENSSL_free(cctx->cert_filename[i]);
         }
-        if (cctx->prefix)
-            OPENSSL_free(cctx->prefix);
+        OPENSSL_free(cctx->prefix);
         OPENSSL_free(cctx);
     }
 }
@@ -688,8 +685,7 @@ int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre)
         if (tmp == NULL)
             return 0;
     }
-    if (cctx->prefix)
-        OPENSSL_free(cctx->prefix);
+    OPENSSL_free(cctx->prefix);
     cctx->prefix = tmp;
     if (tmp)
         cctx->prefixlen = strlen(tmp);
index 7319cd85df44e695f67f1bbac3dc5729c6179a56..5b56ac79e3e9d07cccb659a4c365c23b9ffd85e4 100644 (file)
@@ -570,22 +570,17 @@ void SSL_free(SSL *s)
     /* Free up if allocated */
 
 #ifndef OPENSSL_NO_TLSEXT
-    if (s->tlsext_hostname)
-        OPENSSL_free(s->tlsext_hostname);
+    OPENSSL_free(s->tlsext_hostname);
     SSL_CTX_free(s->initial_ctx);
 # ifndef OPENSSL_NO_EC
-    if (s->tlsext_ecpointformatlist)
-        OPENSSL_free(s->tlsext_ecpointformatlist);
-    if (s->tlsext_ellipticcurvelist)
-        OPENSSL_free(s->tlsext_ellipticcurvelist);
+    OPENSSL_free(s->tlsext_ecpointformatlist);
+    OPENSSL_free(s->tlsext_ellipticcurvelist);
 # endif                         /* OPENSSL_NO_EC */
     sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free);
     if (s->tlsext_ocsp_ids)
         sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free);
-    if (s->tlsext_ocsp_resp)
-        OPENSSL_free(s->tlsext_ocsp_resp);
-    if (s->alpn_client_proto_list)
-        OPENSSL_free(s->alpn_client_proto_list);
+    OPENSSL_free(s->tlsext_ocsp_resp);
+    OPENSSL_free(s->alpn_client_proto_list);
 #endif
 
     sk_X509_NAME_pop_free(s->client_CA, X509_NAME_free);
@@ -603,8 +598,7 @@ void SSL_free(SSL *s)
 #endif                          /* OPENSSL_NO_KRB5 */
 
 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
-    if (s->next_proto_negotiated)
-        OPENSSL_free(s->next_proto_negotiated);
+    OPENSSL_free(s->next_proto_negotiated);
 #endif
 
 #ifndef OPENSSL_NO_SRTP
index 34b6fac2bc9c324c707c78fc6fdc74c9078e693b..a376875803bc853f7f66d2df36a148b13a0f63da 100644 (file)
@@ -931,11 +931,8 @@ int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,
 int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len)
 {
     if (s->version >= TLS1_VERSION) {
-        if (s->tlsext_session_ticket) {
-            OPENSSL_free(s->tlsext_session_ticket);
-            s->tlsext_session_ticket = NULL;
-        }
-
+        OPENSSL_free(s->tlsext_session_ticket);
+        s->tlsext_session_ticket = NULL;
         s->tlsext_session_ticket =
             OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);
         if (!s->tlsext_session_ticket) {
index edb65582f0a4d3cbfa5eaae94d66e5672a14b895..e87d4b396362feb00b8ac4a18209cae6d2a5654a 100644 (file)
@@ -953,10 +953,8 @@ int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
     SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, ERR_R_MALLOC_FAILURE);
     rv = 0;
  ret:
-    if (buff != NULL)
-        OPENSSL_free(buff);
-    if (val != NULL)
-        OPENSSL_free(val);
+    OPENSSL_free(buff);
+    OPENSSL_free(val);
     return (rv);
 }
 
index ce54f4fa15148258ce2506c70783c569262f027a..193cae886ae64a719ebe5f0832310fa374bf6f67 100644 (file)
@@ -195,8 +195,7 @@ int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src)
 
 void custom_exts_free(custom_ext_methods *exts)
 {
-    if (exts->meths)
-        OPENSSL_free(exts->meths);
+    OPENSSL_free(exts->meths);
 }
 
 /* Set callbacks for a custom extension. */
index b77074a0a53ec1ddc3407c4994a6f4860f6adb64..31ebfdde45f58f90da76966acf83cce69f618b14 100644 (file)
@@ -209,9 +209,7 @@ int tls1_new(SSL *s)
 void tls1_free(SSL *s)
 {
 #ifndef OPENSSL_NO_TLSEXT
-    if (s->tlsext_session_ticket) {
-        OPENSSL_free(s->tlsext_session_ticket);
-    }
+    OPENSSL_free(s->tlsext_session_ticket);
 #endif                          /* OPENSSL_NO_TLSEXT */
     ssl3_free(s);
 }
@@ -576,8 +574,7 @@ int tls1_set_curves(unsigned char **pext, size_t *pextlen,
         dup_list |= idmask;
         s2n(id, p);
     }
-    if (*pext)
-        OPENSSL_free(*pext);
+    OPENSSL_free(*pext);
     *pext = clist;
     *pextlen = ncurves * 2;
     return 1;
@@ -1779,8 +1776,7 @@ static int tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data,
     r = s->ctx->alpn_select_cb(s, &selected, &selected_len, data, data_len,
                                s->ctx->alpn_select_cb_arg);
     if (r == SSL_TLSEXT_ERR_OK) {
-        if (s->s3->alpn_selected)
-            OPENSSL_free(s->s3->alpn_selected);
+        OPENSSL_free(s->s3->alpn_selected);
         s->s3->alpn_selected = OPENSSL_malloc(selected_len);
         if (!s->s3->alpn_selected) {
             *al = SSL_AD_INTERNAL_ERROR;
@@ -1894,10 +1890,8 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p,
     s->s3->next_proto_neg_seen = 0;
 # endif
 
-    if (s->s3->alpn_selected) {
-        OPENSSL_free(s->s3->alpn_selected);
-        s->s3->alpn_selected = NULL;
-    }
+    OPENSSL_free(s->s3->alpn_selected);
+    s->s3->alpn_selected = NULL;
 # ifndef OPENSSL_NO_HEARTBEATS
     s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED |
                              SSL_TLSEXT_HB_DONT_SEND_REQUESTS);
@@ -1909,19 +1903,15 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p,
 # endif                         /* !OPENSSL_NO_EC */
 
     /* Clear any signature algorithms extension received */
-    if (s->cert->peer_sigalgs) {
-        OPENSSL_free(s->cert->peer_sigalgs);
-        s->cert->peer_sigalgs = NULL;
-    }
+    OPENSSL_free(s->cert->peer_sigalgs);
+    s->cert->peer_sigalgs = NULL;
 # ifdef TLSEXT_TYPE_encrypt_then_mac
     s->s3->flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC;
 # endif
 
 # ifndef OPENSSL_NO_SRP
-    if (s->srp_ctx.login != NULL) {
-        OPENSSL_free(s->srp_ctx.login);
-        s->srp_ctx.login = NULL;
-    }
+    OPENSSL_free(s->srp_ctx.login);
+    s->srp_ctx.login = NULL;
 # endif
 
     s->srtp_profile = NULL;
@@ -2078,10 +2068,8 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p,
                 return 0;
             }
             if (!s->hit) {
-                if (s->session->tlsext_ecpointformatlist) {
-                    OPENSSL_free(s->session->tlsext_ecpointformatlist);
-                    s->session->tlsext_ecpointformatlist = NULL;
-                }
+                OPENSSL_free(s->session->tlsext_ecpointformatlist);
+                s->session->tlsext_ecpointformatlist = NULL;
                 s->session->tlsext_ecpointformatlist_length = 0;
                 if ((s->session->tlsext_ecpointformatlist =
                      OPENSSL_malloc(ecpointformatlist_length)) == NULL) {
@@ -2387,10 +2375,8 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p,
 # endif
     s->tlsext_ticket_expected = 0;
 
-    if (s->s3->alpn_selected) {
-        OPENSSL_free(s->s3->alpn_selected);
-        s->s3->alpn_selected = NULL;
-    }
+    OPENSSL_free(s->s3->alpn_selected);
+    s->s3->alpn_selected = NULL;
 # ifndef OPENSSL_NO_HEARTBEATS
     s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED |
                              SSL_TLSEXT_HB_DONT_SEND_REQUESTS);
@@ -2442,8 +2428,7 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p,
             }
             if (!s->hit) {
                 s->session->tlsext_ecpointformatlist_length = 0;
-                if (s->session->tlsext_ecpointformatlist != NULL)
-                    OPENSSL_free(s->session->tlsext_ecpointformatlist);
+                OPENSSL_free(s->session->tlsext_ecpointformatlist);
                 if ((s->session->tlsext_ecpointformatlist =
                      OPENSSL_malloc(ecpointformatlist_length)) == NULL) {
                     *al = TLS1_AD_INTERNAL_ERROR;
@@ -2548,8 +2533,7 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p,
                 *al = TLS1_AD_DECODE_ERROR;
                 return 0;
             }
-            if (s->s3->alpn_selected)
-                OPENSSL_free(s->s3->alpn_selected);
+            OPENSSL_free(s->s3->alpn_selected);
             s->s3->alpn_selected = OPENSSL_malloc(len);
             if (!s->s3->alpn_selected) {
                 *al = TLS1_AD_INTERNAL_ERROR;
@@ -2704,11 +2688,9 @@ int tls1_set_server_sigalgs(SSL *s)
     int al;
     size_t i;
     /* Clear any shared sigtnature algorithms */
-    if (s->cert->shared_sigalgs) {
-        OPENSSL_free(s->cert->shared_sigalgs);
-        s->cert->shared_sigalgs = NULL;
-        s->cert->shared_sigalgslen = 0;
-    }
+    OPENSSL_free(s->cert->shared_sigalgs);
+    s->cert->shared_sigalgs = NULL;
+    s->cert->shared_sigalgslen = 0;
     /* Clear certificate digests and validity flags */
     for (i = 0; i < SSL_PKEY_NUM; i++) {
         s->cert->pkeys[i].digest = NULL;
@@ -2860,10 +2842,8 @@ int ssl_check_serverhello_tlsext(SSL *s)
          * Set resp to NULL, resplen to -1 so callback knows there is no
          * response.
          */
-        if (s->tlsext_ocsp_resp) {
-            OPENSSL_free(s->tlsext_ocsp_resp);
-            s->tlsext_ocsp_resp = NULL;
-        }
+        OPENSSL_free(s->tlsext_ocsp_resp);
+        s->tlsext_ocsp_resp = NULL;
         s->tlsext_ocsp_resplen = -1;
         r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg);
         if (r == 0) {
@@ -3408,11 +3388,10 @@ static int tls1_set_shared_sigalgs(SSL *s)
     TLS_SIGALGS *salgs = NULL;
     CERT *c = s->cert;
     unsigned int is_suiteb = tls1_suiteb(s);
-    if (c->shared_sigalgs) {
-        OPENSSL_free(c->shared_sigalgs);
-        c->shared_sigalgs = NULL;
-        c->shared_sigalgslen = 0;
-    }
+
+    OPENSSL_free(c->shared_sigalgs);
+    c->shared_sigalgs = NULL;
+    c->shared_sigalgslen = 0;
     /* If client use client signature algorithms if not NULL */
     if (!s->server && c->client_sigalgs && !is_suiteb) {
         conf = c->client_sigalgs;
@@ -3459,8 +3438,7 @@ int tls1_save_sigalgs(SSL *s, const unsigned char *data, int dsize)
     if (!c)
         return 0;
 
-    if (c->peer_sigalgs)
-        OPENSSL_free(c->peer_sigalgs);
+    OPENSSL_free(c->peer_sigalgs);
     c->peer_sigalgs = OPENSSL_malloc(dsize);
     if (!c->peer_sigalgs)
         return 0;
@@ -3840,13 +3818,11 @@ int tls1_set_sigalgs(CERT *c, const int *psig_nids, size_t salglen,
     }
 
     if (client) {
-        if (c->client_sigalgs)
-            OPENSSL_free(c->client_sigalgs);
+        OPENSSL_free(c->client_sigalgs);
         c->client_sigalgs = sigalgs;
         c->client_sigalgslen = salglen;
     } else {
-        if (c->conf_sigalgs)
-            OPENSSL_free(c->conf_sigalgs);
+        OPENSSL_free(c->conf_sigalgs);
         c->conf_sigalgs = sigalgs;
         c->conf_sigalgslen = salglen;
     }
index 8f71723b31430beea6cf536ea1f60496ed30d018..621fcba506cee5f3bbebae6e719dcb4c7e54f26e 100644 (file)
@@ -195,10 +195,8 @@ int main(int argc, char *argv[])
  err:
     ERR_print_errors_fp(stderr);
 
-    if (abuf != NULL)
-        OPENSSL_free(abuf);
-    if (bbuf != NULL)
-        OPENSSL_free(bbuf);
+    OPENSSL_free(abuf);
+    OPENSSL_free(bbuf);
     DH_free(b);
     DH_free(a);
     BN_GENCB_free(_cb);
index af124764c832cc26547b317bce42359c53775e56..47c8185b7701f321bea1cdef6a35b01da5593628 100644 (file)
@@ -278,10 +278,8 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
  err:
     ERR_print_errors_fp(stderr);
 
-    if (abuf != NULL)
-        OPENSSL_free(abuf);
-    if (bbuf != NULL)
-        OPENSSL_free(bbuf);
+    OPENSSL_free(abuf);
+    OPENSSL_free(bbuf);
     BN_free(x_a);
     BN_free(y_a);
     BN_free(x_b);
@@ -433,8 +431,7 @@ static int ecdh_kat(BIO *out, const char *cname, int nid,
  err:
     EC_KEY_free(key1);
     EC_KEY_free(key2);
-    if (Ztmp)
-        OPENSSL_free(Ztmp);
+    OPENSSL_free(Ztmp);
     if (rv)
         BIO_puts(out, " ok\n");
     else {
index 1eeaabaa04eba02217beb85789c2f25026216a38..52326c5e23b0b15fc00847714b19f05fa9794472 100644 (file)
@@ -504,12 +504,9 @@ int test_builtin(BIO *out)
     EC_KEY_free(wrong_eckey);
     if (ecdsa_sig)
         ECDSA_SIG_free(ecdsa_sig);
-    if (signature)
-        OPENSSL_free(signature);
-    if (raw_buf)
-        OPENSSL_free(raw_buf);
-    if (curves)
-        OPENSSL_free(curves);
+    OPENSSL_free(signature);
+    OPENSSL_free(raw_buf);
+    OPENSSL_free(curves);
 
     return ret;
 }
index 5641d98fee368116311fdddd295fcd53512db977..ac79388fadd9678fd8ab29b96cef1dcb81fbfa8a 100644 (file)
@@ -320,9 +320,7 @@ static int test_EVP_DigestSignInit(void)
     EVP_MD_CTX_cleanup(&md_ctx);
     EVP_MD_CTX_cleanup(&md_ctx_verify);
     EVP_PKEY_free(pkey);
-    if (sig) {
-        OPENSSL_free(sig);
-    }
+    OPENSSL_free(sig);
 
     return ret;
 }
index 68d5bde300d29a870edacae8a03834e729497ff2..7187624d58529945685f31b425874f7d39431a88 100644 (file)
@@ -249,10 +249,8 @@ static void hex_print(const char *name, const unsigned char *buf, size_t len)
 
 static void free_expected(struct evp_test *t)
 {
-    if (t->expected_err) {
-        OPENSSL_free(t->expected_err);
-        t->expected_err = NULL;
-    }
+    OPENSSL_free(t->expected_err);
+    t->expected_err = NULL;
     if (t->out_expected) {
         OPENSSL_free(t->out_expected);
         OPENSSL_free(t->out_got);
@@ -320,10 +318,8 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth)
         t->meth->cleanup(t);
         OPENSSL_free(t->data);
         t->data = NULL;
-        if (t->expected_err) {
-            OPENSSL_free(t->expected_err);
-            t->expected_err = NULL;
-        }
+        OPENSSL_free(t->expected_err);
+        t->expected_err = NULL;
         free_expected(t);
     }
     t->meth = tmeth;
@@ -534,8 +530,7 @@ int main(int argc, char **argv)
 
 static void test_free(void *d)
 {
-    if (d)
-        OPENSSL_free(d);
+    OPENSSL_free(d);
 }
 
 /* Message digest tests */
@@ -861,8 +856,7 @@ static int cipher_test_enc(struct evp_test *t, int enc)
     }
     err = NULL;
  err:
-    if (tmp)
-        OPENSSL_free(tmp);
+    OPENSSL_free(tmp);
     EVP_CIPHER_CTX_free(ctx);
     t->err = err;
     return err ? 0 : 1;
@@ -1049,8 +1043,7 @@ static int mac_test_run(struct evp_test *t)
  err:
     if (mctx)
         EVP_MD_CTX_destroy(mctx);
-    if (mac)
-        OPENSSL_free(mac);
+    OPENSSL_free(mac);
     EVP_PKEY_CTX_free(genctx);
     EVP_PKEY_free(key);
     t->err = err;
@@ -1133,10 +1126,9 @@ static int pkey_test_init(struct evp_test *t, const char *name,
 static void pkey_test_cleanup(struct evp_test *t)
 {
     struct pkey_data *kdata = t->data;
-    if (kdata->input)
-        OPENSSL_free(kdata->input);
-    if (kdata->output)
-        OPENSSL_free(kdata->output);
+
+    OPENSSL_free(kdata->input);
+    OPENSSL_free(kdata->output);
     EVP_PKEY_CTX_free(kdata->ctx);
 }
 
@@ -1185,8 +1177,7 @@ static int pkey_test_run(struct evp_test *t)
         goto err;
     err = NULL;
  err:
-    if (out)
-        OPENSSL_free(out);
+    OPENSSL_free(out);
     t->err = err;
     return 1;
 }
index 311fbc9d613b47e4b61435dcaaa370cddf601b67..8b5ff3e4260922dc1d2ca53852c477e242c737e1 100644 (file)
@@ -466,10 +466,8 @@ static int verify_alpn(SSL *client, SSL *server)
     SSL_get0_alpn_selected(client, &client_proto, &client_proto_len);
     SSL_get0_alpn_selected(server, &server_proto, &server_proto_len);
 
-    if (alpn_selected != NULL) {
-        OPENSSL_free(alpn_selected);
-        alpn_selected = NULL;
-    }
+    OPENSSL_free(alpn_selected);
+    alpn_selected = NULL;
 
     if (client_proto_len != server_proto_len ||
         memcmp(client_proto, server_proto, client_proto_len) != 0) {
@@ -2457,11 +2455,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
     BIO_free(s_to_c);
     BIO_free_all(c_bio);
     BIO_free_all(s_bio);
-
-    if (cbuf)
-        OPENSSL_free(cbuf);
-    if (sbuf)
-        OPENSSL_free(sbuf);
+    OPENSSL_free(cbuf);
+    OPENSSL_free(sbuf);
 
     return (ret);
 }