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>
diff --git a/libasn1fix/asn1fix_crange.c b/libasn1fix/asn1fix_crange.c
index 311c727..4c1f321 100644
--- a/libasn1fix/asn1fix_crange.c
+++ b/libasn1fix/asn1fix_crange.c
@@ -673,10 +673,8 @@
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 db4d4ed..d57e37e 100644
--- a/libasn1fix/asn1fix_tags.c
+++ b/libasn1fix/asn1fix_tags.c
@@ -166,7 +166,7 @@
arg.expr = expr;
count = asn1f_fetch_tags_impl(&arg, &tags, 0, 0, flags);
- if(count <= 0 && tags) {
+ if (count <= 0) {
free(tags);
tags = 0;
}