Hi, I use Python embedded in a huge legacy C base. The python code calls functions in C which then return The result in Python structures. to build up these structures I use functions as PyDict_SetItemString and PyList_Append which insert an item into a dictionary or a list. Normally I don't use the inserted item any longer and must therefore remember by hand to decrement the reference counter to the python item.
have success in finding bugs with this script: @perfect@ expression E1, E2, E3; position p; @@ PyDict_SetItemString@p(E1,E2,E3); ... Py_DECREF(E3); @rule2@ expression E1, E2, E3; position p != perfect.p; @@ PyDict_SetItemString@p(E1,E2,E3); +Py_DECREF(E3); This all goes well, except that the script isn't clever enough to see if E3 actually is referenced later on. Any clues to ensure this script doesn't provide me with false positives? BR Andreas Bach Aaen
_______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
