Skip to content

Instantly share code, notes, and snippets.

@DamienCassou
Created May 8, 2012 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamienCassou/2634899 to your computer and use it in GitHub Desktop.
Save DamienCassou/2634899 to your computer and use it in GitHub Desktop.
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