File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,11 +20,8 @@ main(int argc, char *argv[])
2020 Py_DECREF (pName );
2121
2222 if (pModule != NULL ) {
23- pDict = PyModule_GetDict (pModule );
24- /* pDict is a borrowed reference */
25-
26- pFunc = PyDict_GetItemString (pDict , argv [2 ]);
27- /* pFun: Borrowed reference */
23+ pFunc = PyDict_GetItemString (pModule , argv [2 ]);
24+ /* pFunc is a new reference */
2825
2926 if (pFunc && PyCallable_Check (pFunc )) {
3027 pArgs = PyTuple_New (argc - 3 );
@@ -46,18 +43,19 @@ main(int argc, char *argv[])
4643 Py_DECREF (pValue );
4744 }
4845 else {
46+ Py_DECREF (pFunc );
4947 Py_DECREF (pModule );
5048 PyErr_Print ();
5149 fprintf (stderr ,"Call failed\n" );
5250 return 1 ;
5351 }
54- /* pDict and pFunc are borrowed and must not be Py_DECREF-ed */
5552 }
5653 else {
5754 if (PyErr_Occurred ())
5855 PyErr_Print ();
5956 fprintf (stderr , "Cannot find function \"%s\"\n" , argv [2 ]);
6057 }
58+ Py_XDECREF (pFunc );
6159 Py_DECREF (pModule );
6260 }
6361 else {
You can’t perform that action at this time.
0 commit comments