From: Junio C Hamano Date: Thu, 16 Feb 2017 22:45:13 +0000 (-0800) Subject: Merge branch 'rs/cocci-check-free-only-null' X-Git-Tag: v2.12.0-rc2~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0078a7598518a66c085311a11a0f25203b9ecce6?hp=5a98255dec1578cc6dc3f25e85d7ea96028687b7 Merge branch 'rs/cocci-check-free-only-null' 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 --- diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci index e28213161a..c03ba737e5 100644 --- a/contrib/coccinelle/free.cocci +++ b/contrib/coccinelle/free.cocci @@ -3,3 +3,9 @@ expression E; @@ - if (E) free(E); + +@@ +expression E; +@@ +- if (!E) + free(E);