free NULL cleanup 11
authorRich Salz <rsalz@openssl.org>
Fri, 1 May 2015 14:15:18 +0000 (10:15 -0400)
committerRich Salz <rsalz@openssl.org>
Fri, 1 May 2015 14:15:18 +0000 (10:15 -0400)
Don't check for NULL before calling free functions. This gets:
        ERR_STATE_free
        ENGINE_free
        DSO_free
        CMAC_CTX_free
        COMP_CTX_free
        CONF_free
        NCONF_free NCONF_free_data _CONF_free_data
        A sk_free use within OBJ_sigid_free
        TS_TST_INFO_free (rest of TS_ API was okay)
        Doc update for UI_free (all uses were fine)
        X509V3_conf_free
        X509V3_section_free
        X509V3_string_free

Reviewed-by: Richard Levitte <levitte@openssl.org>
32 files changed:
apps/apps.c
apps/req.c
crypto/asn1/asn1_gen.c
crypto/asn1/asn_mstbl.c
crypto/cmac/cm_ameth.c
crypto/cmac/cmac.c
crypto/comp/c_zlib.c
crypto/conf/conf_api.c
crypto/conf/conf_mod.c
crypto/dso/dso_lib.c
crypto/engine/eng_cnf.c
crypto/engine/eng_dyn.c
crypto/engine/eng_lib.c
crypto/engine/eng_table.c
crypto/err/err.c
crypto/objects/obj_xref.c
crypto/ts/ts_asn1.c
crypto/ts/ts_conf.c
demos/engines/cluster_labs/hw_cluster_labs.c
demos/engines/ibmca/hw_ibmca.c
demos/engines/zencod/hw_zencod.c
engines/e_4758cca.c
engines/e_aep.c
engines/e_atalla.c
engines/e_chil.c
engines/e_cswift.c
engines/e_sureware.c
engines/e_ubsec.c
ssl/s3_enc.c
ssl/ssl_lib.c
ssl/t1_enc.c
test/enginetest.c

index 46cc5a05e71287474ba68440d12352400ab98b3e..f2a17a4633a9b3f1556bcce14d6dc32bb52c6706 100644 (file)
@@ -1612,8 +1612,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
     }
 
  err:
-    if (dbattr_conf)
-        NCONF_free(dbattr_conf);
+    NCONF_free(dbattr_conf);
     TXT_DB_free(tmpdb);
     BIO_free_all(in);
     return retdb;
index 4ff3b246feca424b4193b709244cc4cbeb4f9e69..e8e18ecdde9c47e5be8b44040a0b4090e718d5df 100644 (file)
@@ -883,8 +883,7 @@ int req_main(int argc, char **argv)
     if (sigopts)
         sk_OPENSSL_STRING_free(sigopts);
 #ifndef OPENSSL_NO_ENGINE
-    if (gen_eng)
-        ENGINE_free(gen_eng);
+    ENGINE_free(gen_eng);
 #endif
     OPENSSL_free(keyalgstr);
     X509_REQ_free(req);
index 6756c67a4792c7ec00e8a0876a2f7bdd91023e0d..549bc5ef36850c8cb3d1be19fa9f4a42ae2eebf5 100644 (file)
@@ -511,8 +511,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
     OPENSSL_free(der);
 
     sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
-    if (sect)
-        X509V3_section_free(cnf, sect);
+    X509V3_section_free(cnf, sect);
 
     return ret;
 }
index 889cbe49c8cbe21cf05713d3b2b8d6d2a306d50f..94ffbd8adadf9b1c802be9f77835aa4f9a97583b 100644 (file)
@@ -154,7 +154,6 @@ static int do_tcreate(char *value, char *name)
         if (!rv)
             ASN1err(ASN1_F_DO_TCREATE, ERR_R_MALLOC_FAILURE);
     }
-    if (lst)
-        sk_CONF_VALUE_pop_free(lst, X509V3_conf_free);
+    sk_CONF_VALUE_pop_free(lst, X509V3_conf_free);
     return rv;
 }
index 98634c99e90b0328d7f5554ecc64965bc771d9dc..07853a63d367ec8e9e44863a76389dd46a0ac71e 100644 (file)
@@ -70,8 +70,7 @@ static int cmac_size(const EVP_PKEY *pkey)
 static void cmac_key_free(EVP_PKEY *pkey)
 {
     CMAC_CTX *cmctx = (CMAC_CTX *)pkey->pkey.ptr;
-    if (cmctx)
-        CMAC_CTX_free(cmctx);
+    CMAC_CTX_free(cmctx);
 }
 
 const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
index 19018480f2e1849b075dc8bf0839206649d68c64..5e8fdc399bb7ed59d21ff9879df3036da19725eb 100644 (file)
@@ -115,6 +115,8 @@ EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx)
 
 void CMAC_CTX_free(CMAC_CTX *ctx)
 {
+    if (!ctx)
+        return;
     CMAC_CTX_cleanup(ctx);
     OPENSSL_free(ctx);
 }
index 4508e7f6345a466075607217d87f4241c4560b51..334c78f29668036a159e33e33d4dedb882677e50 100644 (file)
@@ -289,8 +289,7 @@ COMP_METHOD *COMP_zlib(void)
 void COMP_zlib_cleanup(void)
 {
 #ifdef ZLIB_SHARED
-    if (zlib_dso)
-        DSO_free(zlib_dso);
+    DSO_free(zlib_dso);
 #endif
 }
 
index b41564b6803dc79364f0344528df768a71b60aa4..59808a301b6ff6a1a7b9ac1414c3e6d75391e04d 100644 (file)
@@ -241,8 +241,7 @@ static void value_free_stack_doall(CONF_VALUE *a)
         OPENSSL_free(vv->name);
         OPENSSL_free(vv);
     }
-    if (sk != NULL)
-        sk_CONF_VALUE_free(sk);
+    sk_CONF_VALUE_free(sk);
     OPENSSL_free(a->section);
     OPENSSL_free(a);
 }
@@ -251,7 +250,7 @@ static void value_free_stack_doall(CONF_VALUE *a)
 CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 {
     STACK_OF(CONF_VALUE) *sk = NULL;
-    int ok = 0, i;
+    int i;
     CONF_VALUE *v = NULL, *vv;
 
     if ((sk = sk_CONF_VALUE_new_null()) == NULL)
@@ -268,13 +267,10 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
 
     vv = lh_CONF_VALUE_insert(conf->data, v);
     OPENSSL_assert(vv == NULL);
-    ok = 1;
+    return v;
+
  err:
-    if (!ok) {
-        if (sk != NULL)
-            sk_CONF_VALUE_free(sk);
-        OPENSSL_free(v);
-        v = NULL;
-    }
-    return (v);
+    sk_CONF_VALUE_free(sk);
+    OPENSSL_free(v);
+    return NULL;
 }
index ce2b1778731924091ea42f47ee96cc37eb0fd4ef..18fe38b302624d8553b68dbe90e0806e2722ae51 100644 (file)
@@ -266,8 +266,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
     return md;
 
  err:
-    if (dso)
-        DSO_free(dso);
+    DSO_free(dso);
     CONFerr(CONF_F_MODULE_LOAD_DSO, errcode);
     ERR_add_error_data(4, "module=", name, ", path=", path);
     return NULL;
@@ -422,8 +421,7 @@ void CONF_modules_unload(int all)
 /* unload a single module */
 static void module_free(CONF_MODULE *md)
 {
-    if (md->dso)
-        DSO_free(md->dso);
+    DSO_free(md->dso);
     OPENSSL_free(md->name);
     OPENSSL_free(md);
 }
@@ -445,6 +443,8 @@ void CONF_modules_finish(void)
 
 static void module_finish(CONF_IMODULE *imod)
 {
+    if (!imod)
+        return;
     if (imod->pmod->finish)
         imod->pmod->finish(imod);
     imod->pmod->links--;
index a33a8a85bb2124aaa3946e1b774cd9b03c83757d..99701d15d4362befc7a22ae56bd046f251ab4fc1 100644 (file)
@@ -133,10 +133,8 @@ int DSO_free(DSO *dso)
 {
     int i;
 
-    if (dso == NULL) {
-        DSOerr(DSO_F_DSO_FREE, ERR_R_PASSED_NULL_PARAMETER);
-        return (0);
-    }
+    if (dso == NULL)
+        return (1);
 
     i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO);
 #ifdef REF_PRINT
index f09bec4e9ac05b82acf77e29b4dea90195ddd1e3..e84281f22e903e99e1bbfcb5d608602d27330e56 100644 (file)
@@ -194,8 +194,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
                                ", name=", ecmd->name,
                                ", value=", ecmd->value);
     }
-    if (e)
-        ENGINE_free(e);
+    ENGINE_free(e);
     return ret;
 }
 
index 7dd3659e76edfea086920651ad223b8907273fad..02590e026ac85fd6bc06dd867e90f6174a2e3c38 100644 (file)
@@ -186,8 +186,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
 {
     if (ptr) {
         dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
-        if (ctx->dynamic_dso)
-            DSO_free(ctx->dynamic_dso);
+        DSO_free(ctx->dynamic_dso);
         OPENSSL_free(ctx->DYNAMIC_LIBNAME);
         OPENSSL_free(ctx->engine_id);
         if (ctx->dirs)
index 608344064e872bec27f821fa02b359c5340419e5..64b0cadb903b54572b55c38f89eb71eeb6049bac 100644 (file)
@@ -108,16 +108,14 @@ int engine_free_util(ENGINE *e, int locked)
 {
     int i;
 
-    if (e == NULL) {
-        ENGINEerr(ENGINE_F_ENGINE_FREE_UTIL, ERR_R_PASSED_NULL_PARAMETER);
-        return 0;
-    }
+    if (e == NULL)
+        return 1;
     if (locked)
         i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE);
     else
         i = --e->struct_ref;
     engine_ref_debug(e, 0, -1)
-        if (i > 0)
+    if (i > 0)
         return 1;
 #ifdef REF_CHECK
     if (i < 0) {
index 53a6a25600c0ea5be9c035ce92c555ef79fe670e..16eb77143670afde1a2257cff56333b58f939db0 100644 (file)
@@ -216,6 +216,8 @@ void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
 
 static void int_cleanup_cb_doall(ENGINE_PILE *p)
 {
+    if (!p)
+        return;
     sk_ENGINE_free(p->sk);
     if (p->funct)
         engine_unlocked_finish(p->funct, 0);
index 9d58f38144271b9e97c6bf0c72a400db54e0d32f..308504a8ed1825956077268a48a4b1be2b15a394 100644 (file)
@@ -409,8 +409,7 @@ static void int_thread_del_item(const ERR_STATE *d)
     CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
 
     int_thread_release(&hash);
-    if (p)
-        ERR_STATE_free(p);
+    ERR_STATE_free(p);
 }
 
 #ifndef OPENSSL_NO_ERR
@@ -905,8 +904,7 @@ ERR_STATE *ERR_get_state(void)
          * If a race occurred in this function and we came second, tmpp is
          * the first one that we just replaced.
          */
-        if (tmpp)
-            ERR_STATE_free(tmpp);
+        ERR_STATE_free(tmpp);
     }
     return ret;
 }
index 97b305d21363016f4063a3375d2e9918245559b5..b752a2c5beffb968851904df276eaeb324bc5fc1 100644 (file)
@@ -184,14 +184,10 @@ static void sid_free(nid_triple *tt)
 
 void OBJ_sigid_free(void)
 {
-    if (sig_app) {
-        sk_nid_triple_pop_free(sig_app, sid_free);
-        sig_app = NULL;
-    }
-    if (sigx_app) {
-        sk_nid_triple_free(sigx_app);
-        sigx_app = NULL;
-    }
+    sk_nid_triple_pop_free(sig_app, sid_free);
+    sig_app = NULL;
+    sk_nid_triple_free(sigx_app);
+    sigx_app = NULL;
 }
 
 #ifdef OBJ_XREF_TEST
index 7c741d969159aa74303aae729bc281458d9b1550..99b686f39d372bb8eeacd434b82205d00a3fabe4 100644 (file)
@@ -189,8 +189,7 @@ static int ts_resp_set_tst_info(TS_RESP *a)
             TSerr(TS_F_TS_RESP_SET_TST_INFO, TS_R_TOKEN_PRESENT);
             return 0;
         }
-        if (a->tst_info != NULL)
-            TS_TST_INFO_free(a->tst_info);
+        TS_TST_INFO_free(a->tst_info);
         a->tst_info = PKCS7_to_TS_TST_INFO(a->token);
         if (!a->tst_info) {
             TSerr(TS_F_TS_RESP_SET_TST_INFO,
@@ -212,8 +211,7 @@ static int ts_resp_cb(int op, ASN1_VALUE **pval, const ASN1_ITEM *it,
     if (op == ASN1_OP_NEW_POST) {
         ts_resp->tst_info = NULL;
     } else if (op == ASN1_OP_FREE_POST) {
-        if (ts_resp->tst_info != NULL)
-            TS_TST_INFO_free(ts_resp->tst_info);
+        TS_TST_INFO_free(ts_resp->tst_info);
     } else if (op == ASN1_OP_D2I_POST) {
         if (ts_resp_set_tst_info(ts_resp) == 0)
             return 0;
index 4716b2336d65599deed448ea37fd8f13f4879faa..2b856602094cb8f797c0ef281a9ee45a7a350b29 100644 (file)
@@ -230,8 +230,7 @@ int TS_CONF_set_default_engine(const char *name)
         TSerr(TS_F_TS_CONF_SET_DEFAULT_ENGINE, TS_R_COULD_NOT_SET_ENGINE);
         ERR_add_error_data(2, "engine:", name);
     }
-    if (e)
-        ENGINE_free(e);
+    ENGINE_free(e);
     return ret;
 }
 
index c58e548f16d9e623fca9e8ef819c8e8d44142744..918689c215a4a2bcc8380e6b5824e2a6731391d7 100644 (file)
@@ -363,9 +363,7 @@ int cluster_labs_init(ENGINE *e)
 
  err:
     /* reset all pointers */
-    if (cluster_labs_dso)
-        DSO_free(cluster_labs_dso);
-
+    DSO_free(cluster_labs_dso);
     cluster_labs_dso = NULL;
     p_cl_engine_init = NULL;
     p_cl_mod_exp = NULL;
index 082246f92d0cae3a296e8b08c99ade00d5457973..820abe862ef78d2132d915cc550165283ff78b7f 100644 (file)
@@ -412,9 +412,7 @@ static int ibmca_init(ENGINE *e)
 
     return 1;
  err:
-    if (ibmca_dso)
-        DSO_free(ibmca_dso);
-
+    DSO_free(ibmca_dso);
     p_icaOpenAdapter = NULL;
     p_icaCloseAdapter = NULL;
     p_icaRsaModExpo = NULL;
index 0b7221746557ca52b89870e2e57d42873857b6f7..773674f4442631c27e359ce7a169e9d8ad4ab6eb 100644 (file)
@@ -623,9 +623,7 @@ static int zencod_init(ENGINE *e)
 
     return 1;
  err:
-    if (zencod_dso) {
-        DSO_free(zencod_dso);
-    }
+    DSO_free(zencod_dso);
     zencod_dso = NULL;
     ptr_zencod_bytes2bits = NULL;
     ptr_zencod_bits2bytes = NULL;
index 9c98129d98ad1360cb51cbc1d2bad56a10afe953..e592cfb6113d3f624c09fbed3f2543aa208f061e 100644 (file)
@@ -324,8 +324,7 @@ static int ibm_4758_cca_init(ENGINE *e)
 
     return 1;
  err:
-    if (dso)
-        DSO_free(dso);
+    DSO_free(dso);
     dso = NULL;
 
 #  ifndef OPENSSL_NO_RSA
index c86b34adbbb5e686996becec107d17734653dfd3..8a47f7d05773864e9083c52f280a135bad8ec25a 100644 (file)
@@ -501,8 +501,7 @@ static int aep_init(ENGINE *e)
 
  err:
 
-    if (aep_dso)
-        DSO_free(aep_dso);
+    DSO_free(aep_dso);
     aep_dso = NULL;
 
     p_AEP_OpenConnection = NULL;
index e9a6134871a2cf245bf4f92014e33d070f2b4970..278cff427a4a2a5303fb249be00e7ce6654ee556 100644 (file)
@@ -406,8 +406,7 @@ static int atalla_init(ENGINE *e)
     /* Everything's fine. */
     return 1;
  err:
-    if (atalla_dso)
-        DSO_free(atalla_dso);
+    DSO_free(atalla_dso);
     atalla_dso = NULL;
     p_Atalla_GetHardwareConfig = NULL;
     p_Atalla_RSAPrivateKeyOpFn = NULL;
index 35352140af7585549fadb37d67aa76b0496786cb..75c15f69e2ef40c369b786bd61de663ff137e567 100644 (file)
@@ -622,8 +622,7 @@ static int hwcrhk_init(ENGINE *e)
 #  endif
     return 1;
  err:
-    if (hwcrhk_dso)
-        DSO_free(hwcrhk_dso);
+    DSO_free(hwcrhk_dso);
     hwcrhk_dso = NULL;
     p_hwcrhk_Init = NULL;
     p_hwcrhk_Finish = NULL;
index 0b4bfc503e67cf4e797017bd701dfd44c0135f7d..5dcee7cdc7ec9c5a59d9a6b8ea9fa87c6c77f49c 100644 (file)
@@ -431,10 +431,8 @@ static int cswift_init(ENGINE *e)
     /* Everything's fine. */
     return 1;
  err:
-    if (cswift_dso) {
-        DSO_free(cswift_dso);
-        cswift_dso = NULL;
-    }
+    DSO_free(cswift_dso);
+    cswift_dso = NULL;
     p_CSwift_AcquireAccContext = NULL;
     p_CSwift_AttachKeyParam = NULL;
     p_CSwift_SimpleRequest = NULL;
index 9e56a7d28eab712248f86ce6218c8044b5d32a2a..7d8c147db72bc2483f45a0d7356981a0d740aa76 100644 (file)
@@ -560,8 +560,7 @@ static int surewarehk_init(ENGINE *e)
 
     return 1;
  err:
-    if (surewarehk_dso)
-        DSO_free(surewarehk_dso);
+    DSO_free(surewarehk_dso);
     surewarehk_dso = NULL;
     p_surewarehk_Init = NULL;
     p_surewarehk_Finish = NULL;
index c7eb892cf4f881d32b14e70268ba38ee224f80de..a44b0b2b4ac2085c49a9e1852ed34c808f2d9342 100644 (file)
@@ -481,8 +481,7 @@ static int ubsec_init(ENGINE *e)
     }
 
  err:
-    if (ubsec_dso)
-        DSO_free(ubsec_dso);
+    DSO_free(ubsec_dso);
     ubsec_dso = NULL;
     p_UBSEC_ubsec_bytes_to_bits = NULL;
     p_UBSEC_ubsec_bits_to_bytes = NULL;
index df86f5b9f38e8e408bb830e2c6c6a68ea29d8f44..45de404894c19ef810366195019ca729dbd8a270 100644 (file)
@@ -259,10 +259,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
         }
 #ifndef OPENSSL_NO_COMP
         /* COMPRESS */
-        if (s->expand != NULL) {
-            COMP_CTX_free(s->expand);
-            s->expand = NULL;
-        }
+        COMP_CTX_free(s->expand);
+        s->expand = NULL;
         if (comp != NULL) {
             s->expand = COMP_CTX_new(comp);
             if (s->expand == NULL) {
@@ -294,10 +292,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
         }
 #ifndef OPENSSL_NO_COMP
         /* COMPRESS */
-        if (s->compress != NULL) {
-            COMP_CTX_free(s->compress);
-            s->compress = NULL;
-        }
+        COMP_CTX_free(s->compress);
+        s->compress = NULL;
         if (comp != NULL) {
             s->compress = COMP_CTX_new(comp);
             if (s->compress == NULL) {
index 5b56ac79e3e9d07cccb659a4c365c23b9ffd85e4..8eab3e9283cfe7d0a3e0c246fe55ddac8df810bb 100644 (file)
@@ -2860,14 +2860,10 @@ void ssl_clear_cipher_ctx(SSL *s)
         s->enc_write_ctx = NULL;
     }
 #ifndef OPENSSL_NO_COMP
-    if (s->expand != NULL) {
-        COMP_CTX_free(s->expand);
-        s->expand = NULL;
-    }
-    if (s->compress != NULL) {
-        COMP_CTX_free(s->compress);
-        s->compress = NULL;
-    }
+    COMP_CTX_free(s->expand);
+    s->expand = NULL;
+    COMP_CTX_free(s->compress);
+    s->compress = NULL;
 #endif
 }
 
index e87d4b396362feb00b8ac4a18209cae6d2a5654a..5c7fb86a704221d1354db1f8ee48397a9af82286 100644 (file)
@@ -385,10 +385,8 @@ int tls1_change_cipher_state(SSL *s, int which)
         dd = s->enc_read_ctx;
         mac_ctx = ssl_replace_hash(&s->read_hash, NULL);
 #ifndef OPENSSL_NO_COMP
-        if (s->expand != NULL) {
-            COMP_CTX_free(s->expand);
-            s->expand = NULL;
-        }
+        COMP_CTX_free(s->expand);
+        s->expand = NULL;
         if (comp != NULL) {
             s->expand = COMP_CTX_new(comp->method);
             if (s->expand == NULL) {
@@ -425,10 +423,8 @@ int tls1_change_cipher_state(SSL *s, int which)
         } else
             mac_ctx = ssl_replace_hash(&s->write_hash, NULL);
 #ifndef OPENSSL_NO_COMP
-        if (s->compress != NULL) {
-            COMP_CTX_free(s->compress);
-            s->compress = NULL;
-        }
+        COMP_CTX_free(s->compress);
+        s->compress = NULL;
         if (comp != NULL) {
             s->compress = COMP_CTX_new(comp->method);
             if (s->compress == NULL) {
index ab7c0c00dd8432765b8a92d1f5ef1e798950f75a..2d9afaaed1bd5bbd844118a8096aff4c8c593968 100644 (file)
@@ -147,8 +147,7 @@ int main(int argc, char *argv[])
         printf("Remove failed!\n");
         goto end;
     }
-    if (ptr)
-        ENGINE_free(ptr);
+    ENGINE_free(ptr);
     display_engine_list();
     if (!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) {
         printf("Add failed!\n");
@@ -196,8 +195,7 @@ int main(int argc, char *argv[])
         if (!ENGINE_remove(ptr))
             printf("Remove failed!i - probably no hardware "
                    "support present.\n");
-    if (ptr)
-        ENGINE_free(ptr);
+    ENGINE_free(ptr);
     display_engine_list();
     if (!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) {
         printf("Couldn't add and remove to an empty list!\n");
@@ -248,17 +246,12 @@ int main(int argc, char *argv[])
  end:
     if (to_return)
         ERR_print_errors_fp(stderr);
-    if (new_h1)
-        ENGINE_free(new_h1);
-    if (new_h2)
-        ENGINE_free(new_h2);
-    if (new_h3)
-        ENGINE_free(new_h3);
-    if (new_h4)
-        ENGINE_free(new_h4);
+    ENGINE_free(new_h1);
+    ENGINE_free(new_h2);
+    ENGINE_free(new_h3);
+    ENGINE_free(new_h4);
     for (loop = 0; loop < 512; loop++)
-        if (block[loop])
-            ENGINE_free(block[loop]);
+        ENGINE_free(block[loop]);
     ENGINE_cleanup();
     CRYPTO_cleanup_all_ex_data();
     ERR_free_strings();