diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2016-03-15 08:35:24 +0100 |
---|---|---|
committer | Markus Elfring <elfring@users.sourceforge.net> | 2016-03-15 08:35:24 +0100 |
commit | f3d1861b941444d9fb5b52bd7d11b97151adfef0 (patch) | |
tree | 00e3df7ed291255d4d2c3436c6313934048c3fe7 /libasn1fix | |
parent | 671eb9ad14cf62e7f30e01d6dcfd5e813b7ddd49 (diff) |
Bug #86: Deletion of unnecessary checks before calls of the function "free"
The function "free" is documented in the way that no action shall occur for
a passed null pointer. It is therefore not needed that a function caller
repeats a corresponding check.
http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first
This issue was fixed by using the software "Coccinelle 1.0.4".
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Diffstat (limited to 'libasn1fix')
-rw-r--r-- | libasn1fix/asn1fix_crange.c | 6 | ||||
-rw-r--r-- | libasn1fix/asn1fix_tags.c | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/libasn1fix/asn1fix_crange.c b/libasn1fix/asn1fix_crange.c index 311c727c..4c1f3213 100644 --- a/libasn1fix/asn1fix_crange.c +++ b/libasn1fix/asn1fix_crange.c @@ -673,10 +673,8 @@ _range_canonicalize(asn1cnst_range_t *range) { range->right = tmp; } - if(range->elements) { - free(range->elements); - range->elements = 0; - } + free(range->elements); + range->elements = 0; range->el_size = 0; return 0; } diff --git a/libasn1fix/asn1fix_tags.c b/libasn1fix/asn1fix_tags.c index db4d4ed1..d57e37e0 100644 --- a/libasn1fix/asn1fix_tags.c +++ b/libasn1fix/asn1fix_tags.c @@ -166,7 +166,7 @@ asn1f_fetch_tags(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct a arg.expr = expr; count = asn1f_fetch_tags_impl(&arg, &tags, 0, 0, flags); - if(count <= 0 && tags) { + if (count <= 0) { free(tags); tags = 0; } |