diff --git a/esl_bitfield.c b/esl_bitfield.c index fbad3ad5..2375c5b5 100644 --- a/esl_bitfield.c +++ b/esl_bitfield.c @@ -69,8 +69,10 @@ esl_bitfield_Count(const ESL_BITFIELD *b) void esl_bitfield_Destroy(ESL_BITFIELD *b) { - if (b) free(b->b); - free(b); + if (b) { + free(b->b); + free(b); + } } diff --git a/esl_huffman.c b/esl_huffman.c index 57b4fc21..680ba0a2 100644 --- a/esl_huffman.c +++ b/esl_huffman.c @@ -157,12 +157,12 @@ void esl_huffman_Destroy(ESL_HUFFMAN *hc) { if (hc) { - free(hc->len); - free(hc->code); - free(hc->sorted_at); - free(hc->dt_len); - free(hc->dt_lcode); - free(hc->dt_rank); + if(hc->len) free(hc->len); + if(hc->code) free(hc->code); + if(hc->sorted_at) free(hc->sorted_at); + if(hc->dt_len) free(hc->dt_len); + if(hc->dt_lcode) free(hc->dt_lcode); + if(hc->dt_rank) free(hc->dt_rank); free(hc); } } diff --git a/esl_json.c b/esl_json.c index 66f045ca..a0ad52b6 100644 --- a/esl_json.c +++ b/esl_json.c @@ -482,7 +482,7 @@ esl_json_Destroy(ESL_JSON *pi) { if (pi) { - free(pi->tok); + if(pi->tok) free(pi->tok); free(pi); } } diff --git a/esl_minimizer.c b/esl_minimizer.c index 6fa37864..d577fb00 100644 --- a/esl_minimizer.c +++ b/esl_minimizer.c @@ -297,7 +297,7 @@ esl_min_cfg_Destroy(ESL_MIN_CFG *cfg) { if (cfg) { - free(cfg->u); + if(cfg->u) free(cfg->u); free(cfg); } } diff --git a/esl_mixdchlet.c b/esl_mixdchlet.c index 0101d244..fa4f12eb 100644 --- a/esl_mixdchlet.c +++ b/esl_mixdchlet.c @@ -81,9 +81,9 @@ esl_mixdchlet_Destroy(ESL_MIXDCHLET *dchl) { if (dchl) { - free(dchl->q); + if(dchl->q) free(dchl->q); esl_mat_DDestroy(dchl->alpha); - free(dchl->postq); + if(dchl->postq) free(dchl->postq); free(dchl); } } diff --git a/esl_msaweight.c b/esl_msaweight.c index 7b5d6d74..84ea4143 100644 --- a/esl_msaweight.c +++ b/esl_msaweight.c @@ -569,7 +569,7 @@ esl_msaweight_cfg_Create(void) void esl_msaweight_cfg_Destroy(ESL_MSAWEIGHT_CFG *cfg) { - free(cfg); + if(cfg) free(cfg); } diff --git a/esl_rand64.c b/esl_rand64.c index f7fcd217..3badf05a 100644 --- a/esl_rand64.c +++ b/esl_rand64.c @@ -145,7 +145,7 @@ esl_rand64_GetSeed(ESL_RAND64 *rng) void esl_rand64_Destroy(ESL_RAND64 *rng) { - free(rng); + if(rng) free(rng); } diff --git a/esl_random.c b/esl_random.c index e9eecc28..79d0d0cd 100644 --- a/esl_random.c +++ b/esl_random.c @@ -249,7 +249,7 @@ esl_randomness_GetSeed(const ESL_RANDOMNESS *r) void esl_randomness_Destroy(ESL_RANDOMNESS *r) { - free(r); + if(r) free(r); return; } diff --git a/esl_red_black.c b/esl_red_black.c index 56dbfe3f..5dbd5f2e 100644 --- a/esl_red_black.c +++ b/esl_red_black.c @@ -31,13 +31,15 @@ ESL_RED_BLACK_DOUBLEKEY * esl_red_black_doublekey_Create(){ } void esl_red_black_doublekey_Destroy(ESL_RED_BLACK_DOUBLEKEY *tree){ - if(tree->large != NULL){ - esl_red_black_doublekey_Destroy(tree->large); - } - if(tree->small != NULL){ - esl_red_black_doublekey_Destroy(tree->small); + if(tree) { + if(tree->large != NULL){ + esl_red_black_doublekey_Destroy(tree->large); + } + if(tree->small != NULL){ + esl_red_black_doublekey_Destroy(tree->small); + } + free(tree); } - free(tree); } void esl_red_black_doublekey_linked_list_Destroy(ESL_RED_BLACK_DOUBLEKEY *tree){ diff --git a/esl_regexp.c b/esl_regexp.c index 3556e3c4..99e4b0a1 100644 --- a/esl_regexp.c +++ b/esl_regexp.c @@ -111,8 +111,10 @@ void esl_regexp_Destroy(ESL_REGEXP *machine) { /* Spencer's clever alloc for the NDFA allows us to free it w/ free() */ - if (machine->ndfa != NULL) free(machine->ndfa); - free(machine); + if(machine) { + if (machine->ndfa != NULL) free(machine->ndfa); + free(machine); + } return; }