mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-16 18:46:54 +00:00
The coccinelle test "unchecked-strdup.cocci" detects various cases of unchecked strdup().
35 lines
413 B
Plaintext
35 lines
413 B
Plaintext
// find calls to strdup
|
|
@call@
|
|
expression ptr;
|
|
position p;
|
|
@@
|
|
|
|
ptr@p = strdup(...);
|
|
|
|
// find ok calls to strdup
|
|
@ok@
|
|
expression ptr;
|
|
position call.p;
|
|
@@
|
|
|
|
ptr@p = strdup(...);
|
|
... when != ptr
|
|
(
|
|
(ptr == NULL || ...)
|
|
|
|
|
(ptr == 0 || ...)
|
|
|
|
|
(ptr != NULL || ...)
|
|
|
|
|
(ptr != 0 || ...)
|
|
)
|
|
|
|
// fix bad calls to strdup
|
|
@depends on !ok@
|
|
expression ptr;
|
|
position call.p;
|
|
@@
|
|
|
|
ptr@p = strdup(...);
|
|
+ if (ptr == NULL) return;
|