diff options
author | Rich Salz <rsalz@openssl.org> | 2015-05-01 14:37:16 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-05-01 14:37:16 -0400 |
commit | 25aaa98aa249d26391c1994d2de449562c8b8b99 (patch) | |
tree | 6f83efd87fa9fd832e8a456e9686143a29f1dab3 /crypto | |
parent | 666964780a245c14e8f0eb6e13dd854a37387ea9 (diff) |
free NULL cleanup -- coda
After the finale, the "real" final part. :) Do a recursive grep with
"-B1 -w [a-zA-Z0-9_]*_free" to see if any of the preceeding lines are
an "if NULL" check that can be removed.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto')
37 files changed, 93 insertions, 191 deletions
diff --git a/crypto/asn1/a_d2i_fp.c b/crypto/asn1/a_d2i_fp.c index af1f7c6f06..13e47fde08 100644 --- a/crypto/asn1/a_d2i_fp.c +++ b/crypto/asn1/a_d2i_fp.c @@ -97,8 +97,7 @@ void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x) p = (unsigned char *)b->data; ret = d2i(x, &p, len); err: - if (b != NULL) - BUF_MEM_free(b); + BUF_MEM_free(b); return (ret); } @@ -118,8 +117,7 @@ void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) p = (const unsigned char *)b->data; ret = ASN1_item_d2i(x, &p, len, it); err: - if (b != NULL) - BUF_MEM_free(b); + BUF_MEM_free(b); return (ret); } @@ -264,7 +262,6 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) *pb = b; return off; err: - if (b != NULL) - BUF_MEM_free(b); + BUF_MEM_free(b); return -1; } diff --git a/crypto/asn1/p5_pbe.c b/crypto/asn1/p5_pbe.c index a65b659452..ec738ded18 100644 --- a/crypto/asn1/p5_pbe.c +++ b/crypto/asn1/p5_pbe.c @@ -116,8 +116,7 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, return 1; err: - if (pbe != NULL) - PBEPARAM_free(pbe); + PBEPARAM_free(pbe); ASN1_STRING_free(pbe_str); return 0; } diff --git a/crypto/asn1/x_crl.c b/crypto/asn1/x_crl.c index e32556e9ed..a32158b983 100644 --- a/crypto/asn1/x_crl.c +++ b/crypto/asn1/x_crl.c @@ -281,10 +281,8 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, if (!crl->meth->crl_free(crl)) return 0; } - if (crl->akid) - AUTHORITY_KEYID_free(crl->akid); - if (crl->idp) - ISSUING_DIST_POINT_free(crl->idp); + AUTHORITY_KEYID_free(crl->akid); + ISSUING_DIST_POINT_free(crl->idp); ASN1_INTEGER_free(crl->crl_number); ASN1_INTEGER_free(crl->base_crl_number); sk_GENERAL_NAMES_pop_free(crl->issuers, GENERAL_NAMES_free); diff --git a/crypto/cms/cms_cd.c b/crypto/cms/cms_cd.c index aa3238f584..8673e00646 100644 --- a/crypto/cms/cms_cd.c +++ b/crypto/cms/cms_cd.c @@ -105,10 +105,7 @@ CMS_ContentInfo *cms_CompressedData_create(int comp_nid) return cms; err: - - if (cms) - CMS_ContentInfo_free(cms); - + CMS_ContentInfo_free(cms); return NULL; } diff --git a/crypto/cms/cms_dd.c b/crypto/cms/cms_dd.c index d5fda1a5c3..09ad319b87 100644 --- a/crypto/cms/cms_dd.c +++ b/crypto/cms/cms_dd.c @@ -88,10 +88,7 @@ CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md) return cms; err: - - if (cms) - CMS_ContentInfo_free(cms); - + CMS_ContentInfo_free(cms); return NULL; } diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c index f1ac1d535b..ed20c53617 100644 --- a/crypto/cms/cms_enc.c +++ b/crypto/cms/cms_enc.c @@ -194,7 +194,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) ok = 1; err: - if (ec->key && !keep_key) { + if (!keep_key) { OPENSSL_clear_free(ec->key, ec->keylen); ec->key = NULL; } diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index e8274beabf..7fefd246e3 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -168,8 +168,7 @@ CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher) goto merr; return cms; merr: - if (cms) - CMS_ContentInfo_free(cms); + CMS_ContentInfo_free(cms); CMSerr(CMS_F_CMS_ENVELOPEDDATA_CREATE, ERR_R_MALLOC_FAILURE); return NULL; } @@ -400,10 +399,8 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, ret = 1; err: - if (pctx) { - EVP_PKEY_CTX_free(pctx); - ktri->pctx = NULL; - } + EVP_PKEY_CTX_free(pctx); + ktri->pctx = NULL; OPENSSL_free(ek); return ret; diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index 21f41f6a4b..9dfbd67e5f 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -128,9 +128,7 @@ CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, CMSerr(CMS_F_CMS_RECEIPTREQUEST_CREATE0, ERR_R_MALLOC_FAILURE); err: - if (rr) - CMS_ReceiptRequest_free(rr); - + CMS_ReceiptRequest_free(rr); return NULL; } @@ -337,10 +335,8 @@ int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) r = 1; err: - if (rr) - CMS_ReceiptRequest_free(rr); + CMS_ReceiptRequest_free(rr); M_ASN1_free_of(rct, CMS_Receipt); - return r; } @@ -384,9 +380,6 @@ ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si) os = ASN1_item_pack(&rct, ASN1_ITEM_rptr(CMS_Receipt), NULL); err: - if (rr) - CMS_ReceiptRequest_free(rr); - + CMS_ReceiptRequest_free(rr); return os; - } diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c index ea7fb5b8f2..d860f0927d 100644 --- a/crypto/cms/cms_kari.c +++ b/crypto/cms/cms_kari.c @@ -207,10 +207,9 @@ int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk) { EVP_PKEY_CTX *pctx; CMS_KeyAgreeRecipientInfo *kari = ri->d.kari; - if (kari->pctx) { - EVP_PKEY_CTX_free(kari->pctx); - kari->pctx = NULL; - } + + EVP_PKEY_CTX_free(kari->pctx); + kari->pctx = NULL; if (!pk) return 1; pctx = EVP_PKEY_CTX_new(pk, NULL); diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 8066602c9f..d19ec6d02c 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -512,8 +512,7 @@ CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, CMSerr(CMS_F_CMS_SIGN, ERR_R_MALLOC_FAILURE); err: - if (cms) - CMS_ContentInfo_free(cms); + CMS_ContentInfo_free(cms); return NULL; } @@ -614,8 +613,7 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data, merr: CMSerr(CMS_F_CMS_ENCRYPT, ERR_R_MALLOC_FAILURE); err: - if (cms) - CMS_ContentInfo_free(cms); + CMS_ContentInfo_free(cms); return NULL; } diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index bd2e8c096e..0ed06e11b8 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -391,19 +391,17 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) v = NULL; } } - if (buff != NULL) - BUF_MEM_free(buff); + BUF_MEM_free(buff); OPENSSL_free(section); return (1); err: - if (buff != NULL) - BUF_MEM_free(buff); + BUF_MEM_free(buff); OPENSSL_free(section); if (line != NULL) *line = eline; BIO_snprintf(btmp, sizeof btmp, "%ld", eline); ERR_add_error_data(2, "line ", btmp); - if ((h != conf->data) && (conf->data != NULL)) { + if (h != conf->data) { CONF_free(conf->data); conf->data = NULL; } @@ -595,8 +593,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) OPENSSL_free(buf); return (1); err: - if (buf != NULL) - BUF_MEM_free(buf); + BUF_MEM_free(buf); return (0); } diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index c86f22e7d1..638f849c16 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -994,7 +994,6 @@ int i2d_ECPKParameters(const EC_GROUP *a, unsigned char **out) EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) { - int ok = 0; EC_KEY *ret = NULL; EC_PRIVATEKEY *priv_key = NULL; @@ -1075,18 +1074,14 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) if (a) *a = ret; - ok = 1; - err: - if (!ok) { - if (a == NULL || *a != ret) - EC_KEY_free(ret); - ret = NULL; - } - - if (priv_key) - EC_PRIVATEKEY_free(priv_key); - + EC_PRIVATEKEY_free(priv_key); return (ret); + + err: + if (a == NULL || *a != ret) + EC_KEY_free(ret); + EC_PRIVATEKEY_free(priv_key); + return NULL; } int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) @@ -1190,8 +1185,7 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) ok = 1; err: OPENSSL_free(buffer); - if (priv_key) - EC_PRIVATEKEY_free(priv_key); + EC_PRIVATEKEY_free(priv_key); return (ok ? ret : 0); } diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 02de91da91..628e8799d4 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -132,16 +132,11 @@ void EC_GROUP_free(EC_GROUP *group) group->meth->group_finish(group); EC_EX_DATA_free_all_data(&group->extra_data); - BN_MONT_CTX_free(group->mont_data); - EC_POINT_free(group->generator); BN_free(group->order); BN_free(group->cofactor); - - if (group->seed) - OPENSSL_free(group->seed); - + OPENSSL_free(group->seed); OPENSSL_free(group); } diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 115bc4258b..bd99c82516 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -742,8 +742,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) if (ctx != NULL) BN_CTX_end(ctx); BN_CTX_free(new_ctx); - if (pre_comp) - ec_pre_comp_free(pre_comp); + ec_pre_comp_free(pre_comp); if (points) { EC_POINT **p; diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c index 02590e026a..84d8e86c89 100644 --- a/crypto/engine/eng_dyn.c +++ b/crypto/engine/eng_dyn.c @@ -189,8 +189,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr, DSO_free(ctx->dynamic_dso); OPENSSL_free(ctx->DYNAMIC_LIBNAME); OPENSSL_free(ctx->engine_id); - if (ctx->dirs) - sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); + sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); OPENSSL_free(ctx); } } diff --git a/crypto/err/err.c b/crypto/err/err.c index 308504a8ed..e1091e3cf7 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -559,10 +559,8 @@ void ERR_unload_strings(int lib, ERR_STRING_DATA *str) void ERR_free_strings(void) { CRYPTO_w_lock(CRYPTO_LOCK_ERR); - if (int_error_hash) { - lh_ERR_STRING_DATA_free(int_error_hash); - int_error_hash = NULL; - } + lh_ERR_STRING_DATA_free(int_error_hash); + int_error_hash = NULL; CRYPTO_w_unlock(CRYPTO_LOCK_ERR); } diff --git a/crypto/ex_data.c b/crypto/ex_data.c index 66070f6806..96ecd94ca1 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -524,10 +524,8 @@ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) } } OPENSSL_free(storage); - if (ad->sk) { - sk_void_free(ad->sk); - ad->sk = NULL; - } + sk_void_free(ad->sk); + ad->sk = NULL; } /********************************************************************/ diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 402df01fad..dee1fb98f9 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -197,10 +197,10 @@ static CRYPTO_THREADID disabling_threadid; static void app_info_free(APP_INFO *inf) { + if (!inf) + return; if (--(inf->references) <= 0) { - if (inf->next != NULL) { - app_info_free(inf->next); - } + app_info_free(inf->next); OPENSSL_free(inf); } } @@ -559,8 +559,7 @@ void CRYPTO_dbg_free(void *addr, int before_p) fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n", mp->order, mp->addr, mp->num); #endif - if (mp->app_info != NULL) - app_info_free(mp->app_info); + app_info_free(mp->app_info); OPENSSL_free(mp); } @@ -763,10 +762,8 @@ void CRYPTO_mem_leaks(BIO *b) old_mh_mode = mh_mode; mh_mode = CRYPTO_MEM_CHECK_OFF; - if (mh != NULL) { - lh_MEM_free(mh); - mh = NULL; - } + lh_MEM_free(mh); + mh = NULL; if (amih != NULL) { if (lh_APP_INFO_num_items(amih) == 0) { lh_APP_INFO_free(amih); diff --git a/crypto/ocsp/ocsp_cl.c b/crypto/ocsp/ocsp_cl.c index 78d817db9e..0f3f13faf8 100644 --- a/crypto/ocsp/ocsp_cl.c +++ b/crypto/ocsp/ocsp_cl.c @@ -91,8 +91,7 @@ OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid) if (!(one = OCSP_ONEREQ_new())) goto err; - if (one->reqCert) - OCSP_CERTID_free(one->reqCert); + OCSP_CERTID_free(one->reqCert); one->reqCert = cid; if (req && !sk_OCSP_ONEREQ_push(req->tbsRequest->requestList, one)) goto err; @@ -107,6 +106,7 @@ OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid) int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm) { GENERAL_NAME *gen; + gen = GENERAL_NAME_new(); if (gen == NULL) return 0; @@ -115,8 +115,7 @@ int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm) return 0; } gen->type = GEN_DIRNAME; - if (req->tbsRequest->requestorName) - GENERAL_NAME_free(req->tbsRequest->requestorName); + GENERAL_NAME_free(req->tbsRequest->requestorName); req->tbsRequest->requestorName = gen; return 1; } diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c index 91eac9b1c0..8a35f752b2 100644 --- a/crypto/ocsp/ocsp_ext.c +++ b/crypto/ocsp/ocsp_ext.c @@ -437,8 +437,7 @@ X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim) } x = X509V3_EXT_i2d(NID_id_pkix_OCSP_CrlID, 0, cid); err: - if (cid) - OCSP_CRLID_free(cid); + OCSP_CRLID_free(cid); return x; } @@ -516,7 +515,6 @@ X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls) } x = X509V3_EXT_i2d(NID_id_pkix_OCSP_serviceLocator, 0, sloc); err: - if (sloc) - OCSP_SERVICELOC_free(sloc); + OCSP_SERVICELOC_free(sloc); return x; } diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index ac64b65235..62a5812b56 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -142,8 +142,7 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, digerr: OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_DIGEST_ERR); err: - if (cid) - OCSP_CERTID_free(cid); + OCSP_CERTID_free(cid); return NULL; } diff --git a/crypto/ocsp/ocsp_srv.c b/crypto/ocsp/ocsp_srv.c index 00cafea108..1afa68cfd7 100644 --- a/crypto/ocsp/ocsp_srv.c +++ b/crypto/ocsp/ocsp_srv.c @@ -130,8 +130,7 @@ OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs) goto err; return rsp; err: - if (rsp) - OCSP_RESPONSE_free(rsp); + OCSP_RESPONSE_free(rsp); return NULL; } diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index 9e9c948532..d2a5952c9e 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -674,6 +674,7 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, const unsigned char *p = *in; unsigned int magic; unsigned char *enctmp = NULL, *q; + EVP_CIPHER_CTX cctx; EVP_CIPHER_CTX_init(&cctx); if (saltlen) { @@ -736,8 +737,7 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, ret = b2i_PrivateKey(&p, keylen); err: EVP_CIPHER_CTX_cleanup(&cctx); - if (saltlen) - OPENSSL_free(enctmp); + OPENSSL_free(enctmp); return ret; } diff --git a/crypto/pqueue/pqueue.c b/crypto/pqueue/pqueue.c index a4af9f9950..725fe3874f 100644 --- a/crypto/pqueue/pqueue.c +++ b/crypto/pqueue/pqueue.c @@ -82,9 +82,6 @@ pitem *pitem_new(unsigned char *prio64be, void *data) void pitem_free(pitem *item) { - if (item == NULL) - return; - OPENSSL_free(item); } @@ -100,9 +97,6 @@ pqueue_s *pqueue_new() void pqueue_free(pqueue_s *pq) { - if (pq == NULL) - return; - OPENSSL_free(pq); } diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index 9313c93d68..e9ccd7e41d 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -378,8 +378,7 @@ static int rsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, X509_ALGOR *maskHash; pss = rsa_pss_decode(sigalg, &maskHash); rv = rsa_pss_param_print(bp, pss, maskHash, indent); - if (pss) - RSA_PSS_PARAMS_free(pss); + RSA_PSS_PARAMS_free(pss); X509_ALGOR_free(maskHash); if (!rv) return 0; @@ -557,8 +556,7 @@ static ASN1_STRING *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx) goto err; rv = 1; err: - if (pss) - RSA_PSS_PARAMS_free(pss); + RSA_PSS_PARAMS_free(pss); if (rv) return os; ASN1_STRING_free(os); @@ -896,8 +894,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri) os = NULL; rv = 1; err: - if (oaep) - RSA_OAEP_PARAMS_free(oaep); + RSA_OAEP_PARAMS_free(oaep); ASN1_STRING_free(os); return rv; } diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 7611631309..7922188982 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -106,8 +106,7 @@ _STACK *sk_dup(_STACK *sk) ret->comp = sk->comp; return (ret); err: - if (ret) - sk_free(ret); + sk_free(ret); return (NULL); } diff --git a/crypto/store/str_mem.c b/crypto/store/str_mem.c index 8687100761..f1cca6a4e0 100644 --- a/crypto/store/str_mem.c +++ b/crypto/store/str_mem.c @@ -346,7 +346,7 @@ static int mem_list_end(STORE *s, void *handle) STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); return 0; } - if (context && context->search_attributes) + if (context) sk_STORE_ATTR_INFO_free(context->search_attributes); OPENSSL_free(context); return 1; diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c index 3ce765dfa1..a89f9cbdfa 100644 --- a/crypto/ts/ts_rsp_verify.c +++ b/crypto/ts/ts_rsp_verify.c @@ -718,8 +718,7 @@ static int TS_check_signer_name(GENERAL_NAME *tsa_name, X509 *signer) gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx); } - if (gen_names) - GENERAL_NAMES_free(gen_names); + GENERAL_NAMES_free(gen_names); return found; } diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c index 029d0bb2fe..49d8ccc246 100644 --- a/crypto/txt_db/txt_db.c +++ b/crypto/txt_db/txt_db.c @@ -71,7 +71,6 @@ const char TXT_DB_version[] = "TXT_DB" OPENSSL_VERSION_PTEXT; TXT_DB *TXT_DB_read(BIO *in, int num) { TXT_DB *ret = NULL; - int er = 1; int esc = 0; long ln = 0; int i, add, n; @@ -161,36 +160,23 @@ TXT_DB *TXT_DB_read(BIO *in, int num) "wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n", ln, num, n, f); #endif - er = 2; goto err; } pp[n] = p; - if (!sk_OPENSSL_PSTRING_push(ret->data, pp)) { -#if !defined(OPENSSL_NO_STDIO) /* temporary fix :-( */ - fprintf(stderr, "failure in sk_push\n"); -#endif - er = 2; + if (!sk_OPENSSL_PSTRING_push(ret->data, pp)) goto err; - } } - er = 0; + BUF_MEM_free(buf); + return ret; err: BUF_MEM_free(buf); - if (er) { -#if !defined(OPENSSL_NO_STDIO) - if (er == 1) - fprintf(stderr, "OPENSSL_malloc failure\n"); -#endif - if (ret != NULL) { - if (ret->data != NULL) - sk_OPENSSL_PSTRING_free(ret->data); - OPENSSL_free(ret->index); - OPENSSL_free(ret->qual); - OPENSSL_free(ret); - } - return (NULL); - } else - return (ret); + if (ret != NULL) { + sk_OPENSSL_PSTRING_free(ret->data); + OPENSSL_free(ret->index); + OPENSSL_free(ret->qual); + OPENSSL_free(ret); + } + return (NULL); } OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, @@ -242,8 +228,7 @@ int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), return (0); } } - if (db->index[field] != NULL) - lh_OPENSSL_STRING_free(db->index[field]); + lh_OPENSSL_STRING_free(db->index[field]); db->index[field] = idx; db->qual[field] = qual; return (1); @@ -292,8 +277,7 @@ long TXT_DB_write(BIO *out, TXT_DB *db) } ret = tot; err: - if (buf != NULL) - BUF_MEM_free(buf); + BUF_MEM_free(buf); return (ret); } @@ -343,8 +327,7 @@ void TXT_DB_free(TXT_DB *db) if (db->index != NULL) { for (i = db->num_fields - 1; i >= 0; i--) - if (db->index[i] != NULL) - lh_OPENSSL_STRING_free(db->index[i]); + lh_OPENSSL_STRING_free(db->index[i]); |