Merge branch 'rs/cocci-check-free-only-null'
authorJunio C Hamano <gitster@pobox.com>
Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)
A new coccinelle rule that catches a check of !pointer before the
pointer is free(3)d, which most likely is a bug.

* rs/cocci-check-free-only-null:
cocci: detect useless free(3) calls

contrib/coccinelle/free.cocci
index e28213161a4680b266fc76a1052d728b96cbd666..c03ba737e5fafe63218c7023ce8bbd66c47f7dc5 100644 (file)
@@ -3,3 +3,9 @@ expression E;
 @@
 - if (E)
   free(E);
+
+@@
+expression E;
+@@
+- if (!E)
+  free(E);