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 | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 dev/coccinelle/realloc_leak.cocci

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


Reply via email to