Coccinelle semantic patch to find misuses of PyDescr_NewMethod with respect to reference counters in cpython (original) (raw)

Coccinelle semantic patch to find misuses of PyDescr_NewMethod with respect to reference counters in cpython

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@r exists@
local idexpression x;
expression e;
position p1,p2;
@@
x = PyDescr_NewMethod@p1(...)
... when != Py_INCREF(x)
when != Py_XINCREF(x)
when != Py_DECREF(x)
when != Py_XDECREF(x)
when != e = x
when != true x == NULL
(
return <+...x...+>;
|
return@p2 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
cocci.print_main("call",p1)
cocci.print_secs("ret",p2)