Skip to content

Commit ec6cd14

Browse files
rscharfegitster
authored andcommitted
cocci: detect useless free(3) calls
Add a semantic patch for removing checks that cause free(3) to only be called with a NULL pointer, as that must be a programming mistake. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b9e3c2 commit ec6cd14

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

contrib/coccinelle/free.cocci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ expression E;
33
@@
44
- if (E)
55
free(E);
6+
7+
@@
8+
expression E;
9+
@@
10+
- if (!E)
11+
free(E);

0 commit comments

Comments
 (0)