]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEV: coccinelle: Add realloc_leak.cocci
authorTim Duesterhus <tim@bastelstu.be>
Sat, 23 Oct 2021 17:53:35 +0000 (19:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Oct 2021 07:45:48 +0000 (09:45 +0200)
This coccinelle patch finds locations where the return value of `realloc()` is
assigned to the pointer passed to `realloc()`. This calls will leak memory if
`realloc()` returns `NULL`.

dev/coccinelle/realloc_leak.cocci [new file with mode: 0644]

diff --git a/dev/coccinelle/realloc_leak.cocci b/dev/coccinelle/realloc_leak.cocci
new file mode 100644 (file)
index 0000000..c201b80
--- /dev/null
@@ -0,0 +1,6 @@
+@@
+expression E;
+expression F;
+@@
+
+* E = realloc(E, F);