Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Coccinelle semantic patch to find misuses of PyDescr_NewMethod with respect to reference counters in cpython
@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)
@xpidytsolutions
Copy link

I had gone through all you do DamienCassou,
well done. Can we join to work the project together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment